我正在使用php服务器,并且想在.html扩展页面中使用一些php代码 [英] i am using php server and want to use some php code in .html extention page

查看:135
本文介绍了我正在使用php服务器,并且想在.html扩展页面中使用一些php代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在.html扩展页面中使用php代码

is there any possibilities to use php code in .html extention page

推荐答案

您无法在.html文件中运行PHP,因为服务器无法识别除非您告知,否则将其作为有效的PHP扩展.为此,您需要在根Web目录中创建.htaccess文件,并将以下行添加到其中:

AddType应用程序/x-httpd-php .htm .html
这将告诉Apache将扩展名为.htm或.html的文件作为PHP文件进行处理.

请参考此链接 [
You can''t run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this you need to create a .htaccess file in your root web directory and add this line to it:

AddType application/x-httpd-php .htm .html
This will tell Apache to process files with a .htm or .html file extension as PHP files.

Please refer this link[^] for more explanation.


这篇关于我正在使用php服务器,并且想在.html扩展页面中使用一些php代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆