Home  >  Article  >  php教程  >  How to execute php statements in static html files (recommended)

How to execute php statements in static html files (recommended)

高洛峰
高洛峰Original
2016-12-30 11:30:501048browse

The PHP statements in the HTM file will not be executed. How to run php code in the HTML file?

How to execute php statements in html files:

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

You need to modify the http.conf file in the server. .
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 do so by modifying .htaccess.

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 (recommended) for executing php statements on static html files is what I share with you. The entire content is here, I hope it can give everyone a reference, and I also hope everyone will support the PHP Chinese website.

For more methods of executing PHP statements on static HTML files (recommended), please pay attention to the PHP Chinese website for related articles!

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