【问题标题】:Browser is showing PHP code instead of processing it [duplicate]浏览器显示 PHP 代码而不是处理它 [重复]
【发布时间】:2012-10-25 20:34:32
【问题描述】:

可能重复:
PHP code is not being executed (i can see it on source code of page)
web browser not processing PHP code as PHP code

我已经在我的 Windows 8 pro 电脑上安装了 XAMPP。我曾经使用 Windows 7 每次我在 Windows 8 上运行 index.php 文件时,它都会在浏览器 IE10 上显示代码。

这是我所做的:

  1. 我已正确命名文件:index.php
  2. 我已经安装了服务器并将文件保存在 c:/xampp/htdocs/PHP/
  3. 我已经使用<?php ?>打开和关闭所有PHP标签 其他一切似乎都运行良好,例如 PHPMyAdmin 和 php.ini 文件

我不知道怎么了,这让我发疯了......

法里斯

【问题讨论】:

  • 网址是http://localhost ... index.php 而不是file:/// ...??
  • 您使用的是短 php 标签吗?喜欢<? 吗?如果你是,那可能会导致问题。
  • @Dagon 当我打开文件时,位置是 file:///C:// 而不是 localhost/
  • 这就是问题所在。您使用浏览器阅读“原始”文件,您需要通过网络服务器(使用 php)对其进行解析。在浏览器中输入(复制粘贴)http://localhost/index.phphttp://localhost/PHP/index.php
  • @smottt 我正在使用完整的

标签: php xampp


【解决方案1】:

问题是您不是通过网络服务器解析文件,而是直接访问它。

您需要使用网址:

http://localhost/index.php 

或者也许(根据你上面的路径)它的

http://localhost/PHP/index.php

在浏览器中

【讨论】:

  • 通常认为 httpd.conf 可以将所有需要的目录配置为可以通过浏览器访问。默认情况下,只有一个文档根会执行 PHP 代码
  • 是的,但让我们先让基础工作;-)
  • 谢谢,效果很好,非常感谢你们的帮助
猜你喜欢
  • 2020-08-16
  • 1970-01-01
  • 2021-07-31
  • 1970-01-01
  • 2021-12-29
  • 2023-04-10
  • 1970-01-01
  • 2013-05-12
  • 1970-01-01
相关资源
最近更新 更多