当前位置: 移动技术网 > IT编程>开发语言>PHP > 静态html文件执行php语句的方法(推荐)

静态html文件执行php语句的方法(推荐)

2017年12月12日  | 移动技术网IT编程  | 我要评论

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.

以上这篇静态html文件执行php语句的方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网