首頁  >  文章  >  php教程  >  靜態html檔案執行php語句的方法

靜態html檔案執行php語句的方法

高洛峰
高洛峰原創
2016-12-12 09:28:391401瀏覽

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-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 your .

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn