导航首页 » 技术教程 » 静态html文件执行php语句的方法(推荐)
静态html文件执行php语句的方法(推荐) 120 2024-01-10   

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语句的方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持绿夏网。


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103