I am trying to test my php file called home.php
in firefox. I have put the file in htdocs, changed the port settings from default and 80/3306 but no luck. The link I am typing in is localhost/home.php
and not working.
The home.php code.
<?php
<p> echo "Hello World"; </p>
?>
What could be the problem ?
It is saying 'firefox cannot establish a connection to the server at localhost'.
I just restarted the MAMP servers and now it is saying 'Not Found. The requested URL /home.php was not found on this server. '
You are mixing HTML and PHP in a way that causes syntax errors. Try keeping them separate, like this:
<p><?php echo "Hello World"; ?></p>
You should usually avoid embedding HTML tags in your PHP output when possible. However, if you need your tags to be dynamic, you can place them in the output string:
<?php echo "<p>Hello World</p>"; ?>
In response to the newly-added error ("firefox cannot establish a connection to the server at localhost") please verify that you have a web server installed and that it is running at the specified port (80 by default).
<p>
is a html tag this is not define in PHP. Your code is giving error because <P>
is unknown for php. PHP engine not able to compile this html tag you need to care about PHP right syntax