Home Tutorial Php Phpbasics Execute PHP in HTML

 
 

Share on Google+Share on Google+
Execute PHP in HTML
Posted on: October 27, 2009 at 12:00 AM
Advertisement
In this tutorial you will learn about the different ways of executing PHP code into HTML pages.

Execute PHP in HTML

In this tutorial you will learn about the different ways of executing PHP code into HTML pages. In general, we have seen that a page that includes the php code is always named as “. php” because it is the extension of the php file. But in case you do not wanted to change the file name just change the “.htaccess file” and add the following line into it…

1. For HTML
AddType application/x-httpd-php .html

2. For HTM
AddType application/x-httpd-php .htm

There is one more way of doing it… creates a new .php page and add the given lines

<Files my-html-page.html>Add Type application/x-httpd-php.html</Files>

This will make you run your PHP code in .html (my-html-page.html) file.

In the foregoing paragraph we have seen how to execute php in html page. Now lets find out the reason of doing it…

  1. If your page is popular on search engines and giving you lots of traffic, in that situation it’s better to execute php in html page instead of renaming it.
  2. If there is not much programming is required and your page is yet static just execute the php code in HTML.

But I believe that it’s better to change the extension of a page as .php, if we want a dynamic website with lot’s of programming features. This process is know as embedding PHP code in html file, you will learn about it in the next article.

Advertisement

Related Tags for Execute PHP in HTML:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 27, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com