PHP in HTML


#1

Does DreamHost support PHP in HTML. I am embedding some PHP code in my HTML and doesn’t appear to work. However a .PHP file displays fine


#2

In order to execute PHP code, the file must have a .php extension, or you need to use a .htaccess file to add a PHP handler to .html files. Of the two, the preferred thing is to just rename your files to give them the correct (.php) extension.


#3

You can add something like this to your .htaccess file:

AddHandler php5-cgi .html

I wouldn’t call that running PHP within HTML, though. It’s really just treating .html as .php. So, all of your .html files are treated as PHP, not just the ones with PHP code in them.


:stuck_out_tongue: Maximum savings promo code: MaxSavingsAtDH


#4

thanks heaps to those that pointed me in the right direction.

Got it working now - Cheers