简体   繁体   English

php脚本不会运行,只会在浏览器的页面后面显示代码

[英]php script wont run just displays code behind page in browser

When I run localhost/filename.php in the chrome web browser it does not display the output of the code using that filename but the underlying code. 当我在chrome浏览器中运行localhost/filename.php ,它不显示使用该文件名而是基础代码的代码输出。 I have tried to eliminate as many of the possible factors, so I know that the same file works on a different mac when localhost/filename.php is used. 我尝试消除了许多可能的因素,所以我知道当使用localhost/filename.php时,同一文件可在不同的mac上运行。 I have also tried to use it on the safari web browser - same problem. 我也曾尝试在野生动物园网络浏览器中使用它-同样的问题。

I am running out of ideas of how to fix or narrow down the problem so I am just asking on the of chance someone has been in the same situation and knows how to fix it? 我没有解决或缩小问题的想法,所以我只是问是否有人处于相同的情况并且知道如何解决?

I am assuming you have a mac and you are running on the latest version (Mac OS X Mountain Lion), assuming such, you will most likely have to install/enable php this is slightly more difficult than in previous versions of Mac OS X as apple has made some changes, but the link below shows it in pretty good detail, it allows you also to set up phpmyadmin and mysql in a local environment, it's what I used to set it up. 我假设您有一台Mac,并且您正在最新版本(Mac OS X Mountain Lion)上运行,假设是这样,您很可能必须安装/启用php,这比以前版本的Mac OS X更加困难,因为苹果进行了一些更改,但是下面的链接非常详细地显示了它,它还允许您在本地环境中设置phpmyadmin和mysql,这就是我以前设置的内容。

http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion

You can also do something easier and use sever software such as MAMP or XAMPP which are just a simple installer, however they don't offer as much freedom as installing it manually has (also not sure if they have mountain lion support yet)... 您还可以做些简单的事情,并使用服务器软件(例如MAMP或XAMPP),它们只是一个简单的安装程序,但是它们提供的灵活性不如手动安装(也不确定它们是否支持山狮)。 。

MAMP: http://www.mamp.info/de/mamp/index.html MAMP: http//www.mamp.info/de/mamp/index.html

XAMPP: http://www.apachefriends.org/en/xampp-macosx.html XAMPP: http//www.apachefriends.org/en/xampp-macosx.html

Your host is not executing the php so it is not an issue with the code but with PHP. 您的主机未执行php,因此与代码无关,而与PHP无关。 Be sure your localhost is set to execute PHP otherwise it will show it as text. 确保将您的本地主机设置为执行PHP,否则它将以文本形式显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM