Jump to content


Running PHP code in an HTML file

php html

  • Please log in to reply
2 replies to this topic

#1 studius


    Rank I Member

  • Members
  • Pip
  • 27 posts

Posted 10 July 2018 - 11:26 PM



I am trying to run PHP code in an HTML file. I wish to maintain the UX of my website by avoiding the .php extension on pages that my users see whenever possible.


For this reason, I am trying to find a way to run PHP within an HTML file. Upon doing research I found that it is possible to write a .htaccess file but was unsure what code to add to the .htaccess file so that it would work properly on Heliohost's servers (mine is Tommy).


For an Apache server for example, the .htaccess file to solve the issue would be :


AddType application/x-httpd-php .html


Please let me know the best way to achieve the desired functionality on Heliohost servers. Thanks.

#2 rajdis


    Rank II Member

  • Members
  • PipPip
  • 86 posts
  • Gender:Male
  • Location:India

Posted 11 July 2018 - 03:14 AM

Place the PHP code in the HTML file as


<!-- Code -->


And it will work.

server_load_s.gifserver_load_j.gif  server_load_t.gif


#3 wolstech


    Rank X Member

  • Root Admin
  • 13,228 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 July 2018 - 02:28 PM

You change PHP versions and enable .html processing in .htaccess. A line similar to this may already exist if you used MultiPHP manager. In this case, add the .html to the end of the line.

AddType application/x-httpd-ea-php56 .php .php5 .phtml .html

(You can change the php56 portion to the version you want to use, we support php54, php55, php56, php70, php71, php72).


Note that directly modifying this line is incompatible with the MultiPHP manager in cPanel. If you do this, you should not attempt to set a PHP version with MultiPHP manager or it will delete your changes. This line will work in any folder too, so you can have different PHP versions or file extensions for different folders. The MultiPHP manager GUI is limited to per-domain settings only.

Please do not PM me for support. Posting on our forums lets all of us learn.
Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...

Also tagged with one or more of these keywords: php, html

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users