1
votes

I installed MAMP in my macbook with osx mavericks, all preferences are the defaults. I copied my test.html to /Applications/MAMP/htdocs and go to http://localhost:8888/test.html and the display is: one three

and the test.html file:

<html>
<head>
<title>Example</title>
</head>
<body>
one
<?php
echo 'two ';
?>
three
</body>
</html>

The 'two ' of php doesn't appear, anyone knows why?

3
Change your extension to test.php please. :) - Duikboot
thanks! that solved that problem, but I cant solve other I have xD - user2154826

3 Answers

1
votes

Your file is being brought to the browser as an html file. Your server will look to the file extension (in your case .html) in order to figure out what to send to the browser. You need to change the extension to .php so your server will run the php code and then send the resulting html doc to your browser.

0
votes

Another option will be to go to the MAMP folder inside Application, and open httpd.conf (~/Application/MAMP/conf/apache/httpd.conf), then add this to the last line

AddType application/x-httpd-php .php .html

You will need to restart Apache for the changes to take place. You can do that by going to the MAMP window and then clicking "Stop Servers" and "Start Servers". PHP code will be executed inside .html files afterwards.

-1
votes

having a problem using MAMP. The expiration ran out for MAMP and after 5 days my index.php won't be displayed? I ran this the file using apache http://localhost:8888. I even changed it too localhost:80 and the wordpress file I created will display but my personal index.php file doesn't run. I could really use some help figuring this out? Any recommendations would be appreciated, thank you.