I had a similar problem.
Create a new file in TextWrangler or Komodo or something else, and add the following code:
AddType application/x-httpd-php .html .htm AddHandler application/x-httpd-php .html .htm
You are about to save the file as .htaccess (with a dot at the beginning, this is the name of the file). Save it to / Applications / MAMP / htdocs. This is the same place where you save the php and html files. This .htaccess will be an invisible file; you will not see it in Finder, you can, if you connect to it in the terminal, or search in Finder and select the type of file visibility under Kind.
Now try switching to localhost: 8888 / and you will see all the files there. And with this newly created .htaccess file, you can now embed php inside the html file.
source share