HTM文件中的PHP语句不会被执行,如何在HTML文件中运行php代码?
html文件执行php语句的方法:
1,修改httpd.conf,命令Apache把HTML当作PHP,
需要修改服务器里的http.conf文件。
在Apache的httpd.conf中加入以下语句:
AddType application/x-httpd-htm .htm
Action application/x-httpd-htm “/php4/php.exe”
一般的虚拟主机,我们无法修改httpd.conf,但我们可以通过修改.htaccess来实现。
2,修改.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.