PHP 代码显示在浏览器中而不是执行它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7337633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP code display in browser instead of executing it
提问by Avinash
I have just configured the PHP 5.3.8 from PHP.net and apache 2.2.20 from apachelaunge on Windows 7.
我刚刚在 Windows 7 上从 PHP.net 和 apachelaunge 配置了 PHP 5.3.8 和 apache 2.2.20。
Every thing done very well.
每件事都做得非常好。
I have tried PHP -i
from the command line and it show me all PHP infomarmation.
我已经PHP -i
从命令行尝试过,它向我显示了所有 PHP 信息。
But when I have tried to execute the <?php phpinfo(); ?>
, then browsers shows me the same content as in php file but not the actual PHP execution result.
但是当我尝试执行时<?php phpinfo(); ?>
,浏览器显示的内容与 php 文件中的内容相同,但不是实际的 PHP 执行结果。
I have added Directory Index also like below:
我也添加了目录索引,如下所示:
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
I am not getting where I am wrong.
我没有得到我错的地方。
回答by Henry van Megen
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
我发布这个答案是因为我的 Virtualmin/Webmin 管理界面决定禁用我的 PHP 引擎是个好主意..我花了一段时间才找到解决方案,所以我想我会与你们分享:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
另外,请务必检查与此特定主机或虚拟主机相关的网站配置文件中是否没有任何关闭 PHP 的 php_admin_value,如下所示:
php_admin_value engine Off
When in doubt, comment it...
如有疑问,请发表评论...
# php_admin_value engine Off
And restart your webserver.
并重新启动您的网络服务器。
回答by Hammad Khan
Is this phpInfo result any different from the one you are getting from a different server? May be an older version of PHP? The two might not give the same output.
这个 phpInfo 结果与您从不同服务器获得的结果有什么不同吗?可能是旧版本的PHP?两者可能不会给出相同的输出。