Many (maybe most, all?) webservers aren't configured to look for php
script inside html
files out of the box.
Apache, a very popular webserver that you might be running, is an example of such a webserver.
You can, however, configure a webserver, like Apache, to do exactly what you want. If you can't access the Apache configuration files in the Apache directory itself (which is typical on shared servers, which, again, you most likely have), you can configure on a per-directory basis using .htaccess files.
Doing this is pretty simple: open up your favorite text editor, throw this line in there:
AddType application/x-httpd-php .html
and save it as .htaccess
in the same folder as your .html
file. And that should do it.
I'd advise against this, though, as people (like webservers) don't expect there to be php
script inside an html
file. It's good practice to just stick to .php
files for your php
script.