How to execute PHP code from HTML File ???

1 min read

The following post shows a cool way to execute PHP code from files with HTML extension with the help of .htaccess file.

We can write PHP code in a file with HTML extension and run that HTML file on server side thus executing the PHP code written on it.

 

Source Code for index.html

<h1>How to execute PHP code in HTML file ???</h1>


<?php
  for($i=0;$i<100;$i++){
    echo $i.'<br>';
  }
?>

 

Code for .htaccess

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

 

Follow this video for complete guidance :

Recommended For You

About the Author: Ritesh Ghimire