没有被执行PHP code,而不是code显示在页面上 [英] PHP code is not being executed, instead code shows on the page

查看:266
本文介绍了没有被执行PHP code,而不是code显示在页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图执行一些PHP code的一个项目(使用Dreamweaver),但code没有运行。

I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.

当我检查源$ C ​​$ C,PHP的code显示为HTML标签(我可以看到它在源$ C ​​$ C)。 Apache是​​运行正常(我与XAMPP工作),PHP页面正在被正确打开,但没有被执行PHP code。

When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.

是否有人有一个关于正在发生什么建议?

Does someone have a suggestion about what is happening?

注意:的文件已经被命名为 filename.php

Note: The file is already named as filename.php

编辑:
在code ..:

The Code..:

<?
include_once("/code/configs.php");
?>

推荐答案

听起来有一些错误配置,这里有一些事情你可以检查:

Sounds like there is something wrong with your configuration, here's a few things you can check:


  1. 请确保已安装PHP和正常运行。这听起来可能很傻,但你永远不知道。一个简单的检查方法是从一个命令行运行 PHP -v ,看看是否返回版本信息或任何错误。

  1. Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run php -v from a command line and see if returns version information or any errors.

确保PHP模块列并取消注释您的Apache的httpd.conf这应该是这样的的LoadModule php5_moduleC里面:/ PHP / php5apache2_2 .DLL的文件中。搜索的LoadModule PHP ,并确保没有任何注释(; )。在它的前面

Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php, and make sure that there is no comment (;) in front of it.

请确保http.conf文件中有PHP的MIME类型。这应该是类似将AddType应用/ X的httpd - PHP的.php 。这告诉Apache运行的.php 文件作为PHP。搜索将AddType,并确保有PHP的一个条目,这是注释。

Make sure that the http.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php. This tells Apache to run .php files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.

请确保您的文件有就可以了的.php 扩展,或任何扩展在点#3的MIME定义中指定,否则将不被执行作为PHP。

Make sure your file has the .php extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.

请确保你是不是在PHP文件中使用短标签(&LT; ),这些都是德precated线不是所有的服务器的默认情况下启用。使用&LT; PHP 来代替(或启用在php.ini蒙山 short_open_tag的值为=短标记在如果你有code,它依赖于它们)。

Make sure you are not using short tags in the PHP file (<?), these are deprecated not enabled on all servers by default. Use <?php instead (or enable short tags in your php.ini whith short_open_tag=On if you have code that relies on them).

请确保您使用的是URL,比如访问http您的文件通过你的网络服务器$ C>文件://localhost/www/file.php

Make sure you are accessing your file over your webserver using an URL like http://localhost/file.php not via local file access file://localhost/www/file.php

和最后检查 PHP手册进行进一步的设置建议

这篇关于没有被执行PHP code,而不是code显示在页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆