Can you Convert HTML to PHP?

Direct HTML to PHP conversion can not be done, since PHP is a scripting language, and HTML is just a markup language.

Edited: 2012-11-17 12:09

Many beginners often ask if you can just convert your HTML to PHP, failing to understand that PHP is a scripting language. You can change the file extension from .html to .php – but this does not necessarily mean that you will be able to use PHP code in your files.

Your server, or the host where your website is uploaded, will also need to have PHP installed and enabled for you to be able to use PHP code in your files. How to setup your server to use PHP will not be covered in this Article – you should contact your host to find out whether they support PHP.

You do normally not have to output any special mime-type for your files to become HTML, the files will automatically have the content type header set to text/html, but in case the output shows as plain text, try adding the below before sending output to the browser.