执行HTML作为PHP [英] Executing HTML as PHP

查看:187
本文介绍了执行HTML作为PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试嵌入PHP到一个HTML文件,这是行不通的。我编辑我的.htaccess,以便它把HTML文件作为PHP,但当我尝试访问.html文件我的浏览器下载的解析和显示它的它,而不是。

编辑:我的.htaccess的内容:

 将AddType应用/ X的httpd  -  PHP的。html的
 

解决方案

尝试:

 将AddType应用/ X的httpd  -  PHP的.php的.html
RemoveHandler的.php的.html
< FilesMatch |&GT\(PHP HTML)$。;
SetHandler X的httpd  -  PHP
< / FilesMatch>
 

编辑:

根据您的主机上,你可能需要修改它一下,如:

 将AddType应用/的X的httpd-PHP5的.php的.html
RemoveHandler的.php的.html
< FilesMatch |&GT\(PHP HTML)$。;
SetHandler X的httpd  -  PHP5
< / FilesMatch>
 

 将AddType PHP5脚本的.php的.html
RemoveHandler的.php的.html
< FilesMatch |&GT\(PHP HTML)$。;
SetHandler PHP5脚本
< / FilesMatch>
 

When I try to embed PHP into an HTML file, it doesn't work. I edited my .htaccess so that it treats HTML files as PHP, but when I try to visit the .html file my browser downloads it instead of parsing and displaying it.

EDIT: My .htaccess contents:

AddType application/x-httpd-php .html

解决方案

Try:

AddType application/x-httpd-php .php .html
RemoveHandler .php .html
<FilesMatch "\.(php|html)$">
SetHandler x-httpd-php
</FilesMatch>

EDIT:

Depending on your host, you may need to modify it a bit such as:

AddType application/x-httpd-php5 .php .html
RemoveHandler .php .html
<FilesMatch "\.(php|html)$">
SetHandler x-httpd-php5
</FilesMatch>

OR

AddType php5-script .php .html
RemoveHandler .php .html
<FilesMatch "\.(php|html)$">
SetHandler php5-script
</FilesMatch>

这篇关于执行HTML作为PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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