Categories: PHP

How enable HTML files to display php code

When writing content for your site, you typically store them in either html or php files. The basic files, particularly on Linux servers like the ones used for our hosting accounts, are either generally either html (files ending in the extension .html or .htm) or php (files ending in the extension .php) files. HTML files are created with markup tags and these files are not processed or parsed by the server. Php files, on the other hand, are parsed and processed by the server before being displayed in html format to the client browser. Php is a programming style language used to create pages that are processed and served from the server. Php files can always read and display HTML code, but HTML does not automatically parse php code. To do so, you will need to make adjustments to your .htaccess file.              

Enable HTML files to display php code

1) Log into your cPanel

2) Using the File Manager, navigate to the root folder for the domain you want to work with

3) Set the Show Hidden Files option as you will be working with the .htaccess file

4) If there is not one for the domain, you will need to create a new one

5) Edit the file by highlighting the file

6) Click on the Edit icon from the toolbar at the top of the page

5) This brings you to the cpanel file editor. You will want to insert the following line of code at the top of the .htaccess file.

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

6) Then, Click the Save Changes button in the upper right corner of the screen.

7) You are now able to place php code sections into your html files and have them display.

8) Look at the before and after shot to see how the code affects a page with php in it.

 


Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.

Recent Posts

The Ultimate Guide to WordPress Maintenance: Tips and Tricks

When you’re running a business that relies on website traffic and sales to succeed. Then you need to keep it…

4 days ago

Migrate In 2024: Our Comprehensive Website Migration Manual to the Next Level

Migration! Yes, this word is very big in the web hosting industry and it has its importance. Especially for businesses…

6 days ago

Unveiling the Importance of Server Maintenance Plans: A Comprehensive Guide

The server is the backbone of the web hosting industry and it acts like a HERO in the web hosting…

2 weeks ago

IP Address is Blocked? A handpicked list of Solutions to Fix it?

Imagine you are on holiday having a cup of tea and browsing your website or blog.Then, what next?You will get…

3 weeks ago

Explained: Difference between Nameservers Vs. DNS

The web hosting industry is growing every minute, day, and year. It has many terminologies that are important to understand…

1 month ago