Can html execute php methods?

藏色散人
Release: 2023-03-12 16:28:02
Original
3820 people have browsed it

html can execute the php method. The method is: 1. Modify the httpd.conf file and instruct Apache to treat HTML as PHP; 2. Modify .htaccess.

Can html execute php methods?

The operating environment of this article: Windows7 system, PHP5 version, Dell G3 computer

Can html execute the php method?

How to execute PHP statements in static HTML files

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

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”
Copy after login

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.
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Can html execute php methods?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template