PHP 在 XAMPP 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9406433/
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
PHP not working in XAMPP
提问by Loupi
I have a problem running PHP in XAMPP 1.7.7 for windows. I've installed XAMPP in a local server with IIS (changed the port to 81 in httpd.conf as well as other configuration) so far it works and I could connect to the xampp/index.php but coulnd't run any .php files in my htdocs (shows blank except for the html part). It works in my local (also have an IIS installed) but couldn't make it work in a server.
我在 Windows 的 XAMPP 1.7.7 中运行 PHP 时遇到问题。我已经在带有 IIS 的本地服务器中安装了 XAMPP(在 httpd.conf 以及其他配置中将端口更改为 81),到目前为止它可以工作,我可以连接到 xampp/index.php 但无法运行任何 .php我的 htdocs 中的文件(显示空白,除了 html 部分)。它可以在我的本地运行(也安装了 IIS),但无法在服务器中运行。
Any help would be much appreciated.
任何帮助将非常感激。
回答by user28864
If I got your question correctly, I think I had the same problem accessing a php file in XAMPP. I have been online for several hours searching forums and Google for the answer, not until I found the simple solution.
如果我正确回答了您的问题,我想我在访问 XAMPP 中的 php 文件时遇到了同样的问题。我已经在网上搜索了几个小时的论坛和谷歌寻找答案,直到我找到了简单的解决方案。
I was accessing the PHP file as a file on c drive (eg. C:\xamp\htdocs\data.php
or file:///c:/xamp/htdocs/data.php
) instead of as a webpage (ie //localhost/data.php
).
我将 PHP 文件作为 c 驱动器上的文件(例如C:\xamp\htdocs\data.php
或file:///c:/xamp/htdocs/data.php
)而不是网页(即//localhost/data.php
)访问。
I hope this will be helpful to you as well.
我希望这对你也有帮助。
回答by Sir
Create a folder in htdocs like "test".
在 htdocs 中创建一个文件夹,如“test”。
Then in test put index.php with a simple Echo 'Hello';
然后在测试中使用简单的 Echo 'Hello' 放入 index.php;
Then on your browser (make sure apache + mysql are running in control panel).
然后在您的浏览器上(确保 apache + mysql 在控制面板中运行)。
Visit this in your browser:
在浏览器中访问:
http://localhost/test/index.php
http://localhost/test/index.php
If your trying to connect via your IP then your router must be stopping it so you have to sort the settings out. I don't know your router make/model you better off asking their support forums.
如果您尝试通过您的 IP 连接,那么您的路由器必须停止它,因此您必须对设置进行排序。我不知道你的路由器是什么牌子/型号,最好问问他们的支持论坛。
Personally i stuck with port 80. 80 doesn't work in windows 7 because a service is using it. How ever, its a simple fix, just go to "Services" and disable "World Wide Web Publishing Service". Then port 80 is free to use on localhost. (Don't worry your internet will work just fine disabling that service). It'll auto re-enable on next boot so you have to remember that.
我个人坚持使用端口 80。80 在 Windows 7 中不起作用,因为有服务正在使用它。然而,这是一个简单的修复,只需转到“服务”并禁用“万维网发布服务”。然后端口 80 可以在 localhost 上免费使用。(不要担心,禁用该服务后,您的互联网将可以正常工作)。它会在下次启动时自动重新启用,因此您必须记住这一点。
回答by Punit
Use this: //localhost/data.php Instead of this: C:\xamp\htdocs\data.php
使用这个://localhost/data.php 而不是这个:C:\xamp\htdocs\data.php
回答by Andrejs
Make sure you are not running it as a file from your drive, (my example):
确保您没有将其作为驱动器中的文件运行,(我的示例):
*file:///C:/xampp/htdocs/(path)*
but rather as a webpage, which means the address must start with "localhost"
而是作为一个网页,这意味着地址必须以“localhost”开头
*http://localhost/(path)*
If you are using a different port (not the standard 80, but for example 8080), then:
如果您使用不同的端口(不是标准的 80,而是例如 8080),则:
*http://localhost:8080/(path)*
回答by Andrejs
I had the same problem.
For me worked to change <? ... ?>
to <?PHP ... ?>
in the script.
Maybe new wersion of PHP doesn't support the first definition of PHP script.
我有同样的问题。对我来说<? ... ?>
,<?PHP ... ?>
在脚本中更改为。也许新的 PHP 版本不支持 PHP 脚本的第一个定义。
回答by mark anthony tryton novilla
Simply..
简单地..
Save the file/code first(EVERYTIME),
"command + s"
everytime.Refresh the browser.
"command + s"
每次都先(每次)保存文件/代码。刷新浏览器。
good to go
很高兴去