Run php script in html pages

Many people between us want to be able to put their php scripts in html pages without renaming them to .php extension, and here we will get the solution ...

We know that php script can't be executed unless two conditions:
-Must be in a php file.
-Must be between the tags <?php and ?>

But today we will talk about a great solution; you will learn how to put php script in html file.
This is very helpful if you don't want to rename your pages from html or htm extension to php and update all links to it...

The solution is very easy, but to understand it you need to know how php works in server. In apache server, every time a visitor load a file with php extension, the server will ask php to work on it.
We now will ask apache server to execute .html file like .php file , so the server will see .html files like as .php files.

The first step, create .htaccess file in your document root, and if it already exist open it and go to it's end.

In the .htaccess file, add this line and save it:

AddType application/x-httpd-php .html

This will make html page executed as php files.
If you want to add new extension, just add it to this line, like that:

AddType application/x-httpd-php .html .htm

No all is done, you can put your php script in html files ! Enjoy !


D3 Items said...

Such a nice post, My partner and i loved it a great deal! Is fantastic fashion sense! Fantastic images! cheap Diablo iii gold

GW2 Cd key

shorry june said...

in Some years of age time cosplay costumes uk Our god inclined. The very next time have a look at Eastern side Africa via South africa to be able to Somaliland.