php 在浏览器中显示为文本

发布于 2024-11-17 09:40:13 字数 639 浏览 0 评论 0原文

我尝试测试的 PHP 文件在浏览器中显示为文本。最初他们尝试下载而不是显示,但我能够解决这个问题。我安装了 MAMP (Mac OS X Apache MySQL PHP),当我输入 php -v 时进入终端,它返回

PHP 5.2.14 (cli) (built: Oct  6 2010 16:57:10) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies 

表明 php 已安装。我在站点和 MAMP 中都有 phpmyadmin,并且(现在再次测试)站点版本似乎以文本形式打开,并且来自 htdocs 的 MAMP 代码仍在尝试下载 php.ini 文件。在我的 httpd.conf 文件中,我有行

AddType application/x-httpd-php .php .phtml

编辑:我的 MAMP PHP 首选项默认为 PHP 5.3.5,带有 PHP 5.2.17 选项,但是我运行的版本似乎是 5.2.14,这可能是问题?

PHP files I am trying to test are appearing as text in my browser. Initially they were trying to download instead of display, but I was able to fix that. I have MAMP (Mac OS X Apache MySQL PHP) installed and when I entered php -v into the terminal it returned

PHP 5.2.14 (cli) (built: Oct  6 2010 16:57:10) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies 

indicating that php is installed. I have phpmyadmin in both Sites and MAMP, and (while testing it again right now) it appears that the Sites version is opening as text and the MAMP code from htdocs is still trying to download the php. in my httpd.conf file, i have the line

AddType application/x-httpd-php .php .phtml

edit: my MAMP PHP preferences defaults to PHP 5.3.5 with the option of PHP 5.2.17, however the version I am running seems to be 5.2.14, could this be part of the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我偏爱纯白色 2024-11-24 09:40:13

AddType 应用程序/x-httpd-php .php .phtml
应该添加到 httpd.conf

您还需要确保 php 包含(未注释)在 apache 启动时加载的库中。

还记得每次进行更改时都重新启动 apache。

AddType application/x-httpd-php .php .phtml
Should be added in the httpd.conf

You'll also wanna make sure that php is included (not commented) out in the libraries that are loaded when apache starts.

also remember to restart apache every time you make a change.

绝不放开 2024-11-24 09:40:13

您是否还添加了将 PHP 模块加载到 Apache 的行?

LoadModule php5_module "libexec/apache2/libphp5.so"

Did you also add the line for loading the PHP module to Apache?

LoadModule php5_module "libexec/apache2/libphp5.so"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文