Parsing PHP code within HTML pages

The easiest way to parse or run PHP code within an HTML page is to simply change the extension of the page from .html or .htm to .php!

Any regular text or HTML tags within the file will be totally ignored by PHP. Only the code contained within the PHP tags (<? ?>) will be processed by PHP.

If you have many HTML pages that contain PHP code and do not want to go through the trouble of renaming each file (although that method is preferred) you may make a change in the .htaccess file to parse all HTML files as PHP:

Open a text editor such as wordpad, notepad, nano, etc. and add the following line:

AddHandler application/x-httpd-php5 .html .htm

  • 0 Users Found This Useful
這篇文章有幫助嗎?

相關文章

PHP 5.4 vs 5.3 differences : What to watch out for

Each major release of any framework can make someone begin to second-guess what is still...

How to use the PHP mail function

You can use the PHP mail() function to send an email with PHP. The simplest way to do this is...

Change/Select PHP version

If you require a different version of PHP than which we run by default you can select which...

Ruby on Rails

For information about Ruby on Rails, visit their website.