浏览器显示 PHP 代码而不是处理它

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13241738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:01:54  来源:igfitidea点击:

Browser is showing PHP code instead of processing it

phpxampp

提问by FarrisFahad

Possible Duplicate:
PHP code is not being executed (i can see it on source code of page)
web browser not processing PHP code as PHP code

可能的重复:
未执行 PHP 代码(我可以在页面的源代码上看到它)
Web 浏览器未将 PHP 代码处理为 PHP 代码

I have installed XAMPP on my computer which is Windows 8 pro. I use to work with Windows 7 every time I run the index.phpfile on Windows 8 it shows the code on the browser IE10.

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

Here is what I have done:

这是我所做的:

  1. I have named the file correctly: index.php
  2. I have installed the server and saved the files inside c:/xampp/htdocs/PHP/
  3. I have used <?php ?>to open and close all PHP tags and everything else seems working fine, like, PHPMyAdmin, and the php.ini file
  1. 我已正确命名文件: index.php
  2. 我已经安装了服务器并将文件保存在里面 c:/xampp/htdocs/PHP/
  3. 我曾经<?php ?>打开和关闭所有 PHP 标签,其他一切似乎都运行良好,例如 PHPMyAdmin 和 php.ini 文件

I don't know whats wrong and it is driving me crazy ...

我不知道出了什么问题,这让我发疯......

Farris

法里斯

回答by

The problem is you're not parsing the file via the web server, but accessing it directly.

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

you need to use the url:

您需要使用以下网址:

http://localhost/index.php 

or maybe (based on your path above) its

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

http://localhost/PHP/index.php

in the browser

在浏览器中