php 在浏览器中显示为文本
我尝试测试的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
您是否还添加了将 PHP 模块加载到 Apache 的行?
Did you also add the line for loading the PHP module to Apache?