PHP not working in XAMPP

一世执手 提交于 2019-11-27 09:14:48
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.

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).

I hope this will be helpful to you as well.

Create a folder in htdocs like "test".

Then in test put index.php with a simple Echo 'Hello';

Then on your browser (make sure apache + mysql are running in control panel).

Visit this in your browser:

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.

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.

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"

*http://localhost/(path)*

If you are using a different port (not the standard 80, but for example 8080), then:

*http://localhost:8080/(path)*

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.

Use this: //localhost/data.php Instead of this: C:\xamp\htdocs\data.php

mark anthony tryton novilla

Simply..

  1. Save the file/code first(EVERYTIME),"command + s" everytime.

  2. Refresh the browser.

good to go

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!