Actullay我的网站是“http://castleandking.com/”它工作正常。当我们尝试在另一台服务器(http://solomotw.com/castleandking/)设置它时,浏览器显示php代码。你可以在http://solomotw.com/castleandking/检查php代码....请建议我,问题是什么。
答案 0 :(得分:0)
好像你的配置有问题,或者你已经保存了没有扩展名的PHP文件.php
在名为info.php的同一路径上创建一个新的PHP文件并放入以下代码行,然后尝试运行它并查看它显示的内容,
RES._body = {"translations":[{"score":3,"date":"Tue Apr 10 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)","expr":"'風力発電' OR '風力発電機'","lang":"cn","langFull":"Simplified Chinese (中文)","dateHuman":"a month ago"},{"score":5,"date":"Tue Apr 30 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)","expr":"pale OR lame OR hélice","lang":"fr","langFull":"French (Français)","dateHuman":"8 days ago"},{"score":10,"date":"Tue Apr 19 2018 11:35:36 GMT+0200 (W. Europe Daylight Time)","expr":"blade OR strip OR (winding* NEAR2 (turbine OR power OR generator))","lang":"en","langFull":"English","dateHuman":"19 days ago"}]
JSON.parse = { "translations" : [
{
"score": 3,
"date": "Tue Apr 10 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "'風力発電' OR '風力発電機'",
"lang": "cn", // <--------------------------- HERE OK
"langFull": "Simplified Chinese (中文)",
"dateHuman": "a month ago"
},
{
"score": 5,
"date": "Tue Apr 30 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "pale OR lame OR hélice",
"lang": "fr",
"langFull": "French (Français)",
"dateHuman": "8 days ago"
},
{
"score": 10,
"date": "Tue Apr 19 2018 11:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "blade OR strip OR (winding* NEAR2 (turbine OR power OR generator))",
"lang": "en",
"langFull": "English",
"dateHuman": "19 days ago"
}
]}
res.json() = { "translations": [
{
"score": 3,
"date": "Tue Apr 10 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "'風力発電' OR '風力発電機'",
"lang": "cn", // <--------------------------- HERE OK
"langFull": "Simplified Chinese (中文)",
"dateHuman": "a month ago"
},
{
"score": 5,
"date": "Tue Apr 30 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "pale OR lame OR hélice",
"lang": "fr",
"langFull": "French (Français)",
"dateHuman": "8 days ago"
},
{
"score": 10,
"date": "Tue Apr 19 2018 11:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "blade OR strip OR (winding* NEAR2 (turbine OR power OR generator))",
"lang": "en",
"langFull": "English",
"dateHuman": "19 days ago"
}
]}
response = { "translations": [
{
"score": 3,
"date": "Tue Apr 10 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "'風力発電' OR '風力発電機'",
"lang": undefined, // <--------------------------- HERE WTF???
"langFull": "Simplified Chinese (中文)",
"dateHuman": "a month ago"
},
{
"score": 5,
"date": "Tue Apr 30 2018 13:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "pale OR lame OR hélice",
"lang": "fr",
"langFull": "French (Français)",
"dateHuman": "8 days ago"
},
{
"score": 10,
"date": "Tue Apr 19 2018 11:35:36 GMT+0200 (W. Europe Daylight Time)",
"expr": "blade OR strip OR (winding* NEAR2 (turbine OR power OR generator))",
"lang": "en",
"langFull": "English",
"dateHuman": "19 days ago"
}
]}
如果您能看到Apache和PHP的详细信息,这意味着您的PHP和Apache工作正常。
下一个可能的问题可能是您已经以16位编码保存了PHP文件,因为php5默认情况下不识别16位编码。
可能存在第三个问题,请确保您的Apache配置文件<?php
phpinfo();
?>
文件具有以下代码行:
httpd.conf
这是为了确保它确实启用PHP MIME类型来处理PHP文件。
请记住,错误的.htaccess文件配置也会导致类似的问题。
此外,请尝试直接通过AddType application/x-httpd-php .php
等文件名访问您的文件。