Run Php code in html files

In this tutorial we will show you to Run Php code in html files. PHP is most popular server-side script in the world now. HTML is great for SEO purpose. executing PHP script is possible in HTML file.

What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.

Just use following code in your .htaccess file or Apache configuration file.

AddType application/x-httpd-php .html

Or for .htm

AddType application/x-httpd-php .htm

If you only plan on including the PHP on one page, it is better to setup this way:

AddType application/x-httpd-php .html
I found following article useful.
http://php.about.com/od/advancedphp/p/html_php.htm

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “Run Php code in html files”

Leave a Reply

Your email address will not be published.