一般html文件中的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.
以上这篇静态html文件执行php语句的方法就是全部内容了,看起来很简单,希望能给大家一个参考。
关于更多html以及php的相关问题,大家可以访问。
以上就是关于静态html文件执行php语句的方法的详细内容。