Reputation: 65
I am trying to display my php files but all I seem to get is the source code. I am running mac 10.7.5 I have installed MAMP and added a file (test.php) to the htdocs folder. I have turned the apache server on.
the code in the file is
<html>
<head>
<title>:-)</title>
</head>
<body>
<?php
echo "<p>Hello, world. I'm a php file.</p>";
?>
</body>
</html>
and when I point my browser (chrome) to this file it shows the source code exactly as above.
Any help would be great!
Thanks.
Upvotes: 0
Views: 3612
Reputation: 19617
The issue is that you're accessing the script using the file protocol. I guessed as much as I've hit the snag more than once after some late night coding :) .
Try accessing it using the address such as http://localhost/yourfolder/test.php
. The part after localhost is relative to htdocs. If MAMP is up and running this will trigger an HTTP request to Apache and get PHP to interpret the file.
Upvotes: 3