r/PHPhelp 9d ago

PHP in HTML files displays, doesn't execute

/r/apache/comments/1vytv5f/php_in_html_files_displays_doesnt_execute/
0 Upvotes

3 comments sorted by

7

u/No_Astronomer9508 9d ago

Your problem is, that html is not affected by the php parser. You can include html files into php files, but php files included in html files will never work. The file extension ".php" will tell apache to start the php parser. HTML will not do that.

2

u/abillionsuns 9d ago

You definitely can configure Apache to serve .html as PHP, the question is more should you. It introduces some potential security concerns.

5

u/No_Astronomer9508 8d ago

As long as he don't configures apache with something like ""AddHandler application/x-httpd-php .html" in his virtualhost settings, it will not work. And you are absolutely right because of security concerns.