Home  >  Article  >  Backend Development  >  About how to execute php statements on static html files

About how to execute php statements on static html files

小云云
小云云Original
2017-11-09 11:11:422407browse

Generally, PHP statements in HTML files will not be executed, so is there any way to run PHP code in HTML files? The editor has found some methods for you, hoping to help you.

How to execute php statements in html files:

1. Modify httpd.conf and instruct Apache to treat HTML as PHP.

Need to modify http in the server .conf file.

Add the following statement to Apache's httpd.conf:

AddType application/x-httpd-htm .htm
Action application/x-httpd-htm “/php4/php.exe”

For general virtual hosts, we cannot modify httpd.conf, but we can modify .htaccess accomplish.

2, modify .htaccess

NEW PHP Add Handlers
SolutionIf you need an add handler for PHP please use the following:
#PHP5
AddHandler application/x-httpd-php5 .html .htm
#PHP4
AddHandler application/x-httpd-php4 .html .htm
That is if you need to parse .html files or any other extension as PHP you can place that in your .htaccess file.

The above method of executing php statements in static html files is the whole content. It seems very simple. I hope it can give everyone a reference.

For more HTML and PHP related issues, you can visit the php Chinese website.


The above is the detailed content of About how to execute php statements on static html files. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn