0

When I open this php file, it does not load:

<?php 
    echo "I am awesome";
?>
<html>
<head> </head>
</html>

Error screenshot

enter image description here However, if I remove the <head> tag, code works fine.

I've used both Xampp and Wamp servers on Windows PC, tried changing ports but the issue still persists.

Solved: Using http://127.0.0.1/test.php instead of http://localhost/test.php fixed the problem for me and code executed successfully.

Vikram
  • 11
  • 1

3 Answers3

1

First make sure that your Apache is started successfully (either in xampp or wamp).

If Apache is not started. Try closing applications that might use port 80 of your computer.

OR

Change server port in xampp or wamp configurations. Here is guides to perform that:

Change port in xampp

Change port in wamp

TheDevWay
  • 1,363
  • 1
  • 16
  • 45
  • Apache starts successfully. Browser even runs the file without . – Vikram Nov 13 '17 at 12:39
  • @Vikram is HTML tag and is totally unrelated to apache. Html does not need any web server to get executed. Make sure you don't have any proxy or VPN opened. – TheDevWay Nov 13 '17 at 12:48
  • @Vikram What is the url that you enter into your browser ? – TheDevWay Nov 13 '17 at 12:50
  • @Vikram Try localhost and see if it lists your directories and apache functions normally – TheDevWay Nov 15 '17 at 07:21
  • localhost is not working as well but 127.0.0.1 opens the dashboard. And when I tried http://127.0.0.1/test.php, it worked! I'm still trying to understand what happened – Vikram Nov 17 '17 at 10:10
0

Maybe your Apache server is not working properly, You config again and restart your apache server. enter image description here

  • Apache server seems to work fine. Yet I've tried changing ports multiple times. Also, code works in other computers but not mine. – Vikram Nov 13 '17 at 12:37
-1

I think you have saved it as html. Change it to php.

Victor1224
  • 11
  • 1