我们遇到了一个奇怪的问题,我们正在使用几个月前购买的在线订购平台脚本。从前几个月到现在,它一直工作得很好!该网站的页面无法加载,检查Chrome和Firefox检查器,我们看到一个错误说:
list.php正在从index.php调用,通过这一行:
<script type="text/javascript" src="panel/js/list.php"></script>
我认为浏览器,看到/读取文件作为一个JavaScript,然后它发现内部的文件PHP代码,这就是为什么它通过讨厌的错误和阻止页面加载。
我只是想知道如何使php工作,即使它是在<script> </script>
PS: <?php include('panel/js/list.php'); ?>
和<?php require('panel/js/list.php'); ?>
都不起作用
PPS:我试着把那行放在前面,也没有积极的结果
下面是list.php 中的代码<?php
function GetLangFile($lang)
{
$lang_file = 'lang.'.$lang.'.php';
return $_SERVER['DOCUMENT_ROOT'].'/languages/'.$lang_file;
}
// Get language from get or put default as en
$lang_file;
if(isset($_GET['l']) && $_GET['l'] != '')
$lang_file = GetLangFile($_GET['l']);
else
$lang_file = GetLangFile('en');
// Include the selected language file
include_once $lang_file;
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))ob_start("ob_gzhandler");else ob_start();
header("Content-type: text/javascript; charset: UTF-8");
include('md5.js');
include('front.js');
include('shopping.js');
include('paypal.js');
include('mercadopago.js');
include('adsmanager.js');
include('tags.js');
include('front-visuals.js');
include('browserdetect.js');
include('popup.js');
include('social.js');
include('forms.js');
include('uploader.js');
include('googlemap.js');
include('switch.js');
include('howbox.js');
include('tip.js');
include('jCarouselLite.js');
ob_end_flush();
?>
PHP
不是JavaScript
script
。你不能把它包括进去。
我认为浏览器将该文件视为JavaScript
你不能因为这个责怪浏览器,不是吗?你指定它为text/javascript
,
<script type="text/javascript" src="panel/js/list.php"></script>
还请告诉我们list.php
是什么