websmoken Posted January 8, 2008 Share Posted January 8, 2008 I've read somewhere that its possible to use PHP code on a .html or .htm page. Could someone enlighten me on that or point me in the right direction. Thanks Dave Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/ Share on other sites More sharing options...
mika Posted January 8, 2008 Share Posted January 8, 2008 Just tag your PHP code <? ... your code ... ?> and put it in your .htm/.html file. If PHP is well configured it should work. I thin this is what you meant. Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433463 Share on other sites More sharing options...
rajivgonsalves Posted January 8, 2008 Share Posted January 8, 2008 you have to do some apache server settings for that... so that the Php interpreter processes the PHP code Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433465 Share on other sites More sharing options...
Wuhtzu Posted January 8, 2008 Share Posted January 8, 2008 Sorry to say it Mika, but if PHP is poorly configured <? ... your code ... ?> should work You should favor <?php ?> tags over <? ?> But other than that mika is completely right. You simply put your php code inside an opening and a closing tag: <html> <head> <title><?php echo $title; ?></title> </head> <body> <p><?php echo $something; ?></title> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433469 Share on other sites More sharing options...
rajivgonsalves Posted January 8, 2008 Share Posted January 8, 2008 I would have to hate to differ on the above point it will not work until you have the following setting in apache AddType application/x-httpd-php .html .php .htm thats is the apache configration file... just by putting the <?php tag it won't work!! Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433472 Share on other sites More sharing options...
Wuhtzu Posted January 8, 2008 Share Posted January 8, 2008 Then shouldn't we refer to a installation guide... a PHP interpreter needs to be installed as well as that line added to the apache config file. http://php.net/install.windows Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433492 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Rename the extension to .php Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433493 Share on other sites More sharing options...
rajivgonsalves Posted January 8, 2008 Share Posted January 8, 2008 Well I am going with portability in code... most server do not run .html as php... Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433494 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Well I am going with portability in code... most server do not run .html as php... Really!? Wow, I didn't know that. Thanks Learn something new everyday Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433495 Share on other sites More sharing options...
richardw Posted January 8, 2008 Share Posted January 8, 2008 Also, you can add the code posted by rajivgonsalves into an ".htaccess" file and place it in your files directory and the html and htm files will process the php code. Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433733 Share on other sites More sharing options...
pigskins Posted January 8, 2008 Share Posted January 8, 2008 My web host just moved to a new provider and the new servers do not run .html through php. Fyi. Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433804 Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 I doubt any server has it set as default to parse html files as php. Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-433812 Share on other sites More sharing options...
websmoken Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks Guys I would have got back sooner but had to go out of town. I know how to use PHP & HTML together, but always had to save as a FILENAME.PHP. I will try your solutions. I think that rajivgonsalves had what I had seen before. Again Thanks for all the input. I'll mark this as solved. Dave Quote Link to comment https://forums.phpfreaks.com/topic/85007-solved-using-php-on-a-htm-or-html-page/#findComment-434762 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.