在HTML中的PHP文件不运行或者被注释掉 [英] PHP in HTML files not running or being commented out

查看:560
本文介绍了在HTML中的PHP文件不运行或者被注释掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我并不想在一个js脚本运行PHP的,有在这里一个类似的问题是指用户试图从一个js脚本中运行PHP。

First of all, I am not trying to run php within a js script, there is a similar question on here that refers to a user trying to run php from inside a js script.

我添加的多种组合

将AddType应用/ X的httpd - PHP的.php的.html

AddType application/x-httpd-php .php .html

AddHandler的X的httpd - PHP的。html的

AddHandler x-httpd-php .html

要在包含.html文件我要运行PHP在一个更高的层次目录中的.htaccess文件。这没有奏效。 (我很愿意尝试新的组合)

to the .htaccess file in a higher level directory containing the .html file I want to run php in. This has not worked. (I am open to trying new combinations)

的或者是不读的全部或broswer查看源代码时注释掉。

The is either not read at all or commented out when viewing the source in broswer.

我的问题是怎么去是一个HTML文件内运行,或者有没有更好的办法,包括在HTML文档的php功能,而无需在同一个文档中的code。

My question is how to get to be run inside of an html file OR is there a better way to include php functionality in an html document without having the code in the same document.

此外我的主机使用的cPanel如果这有助于什么。

Additionally my host uses cpanel if this helps anything.

我可以在任何详细说明我需要,先谢谢了。

I can elaborate on anything I need to, thanks in advance.

推荐答案

您可以尝试使用的mod_rewrite 该任务:

You can try to use mod_rewrite for that task:

RewriteEngine On
RewriteRule ^(.*).html index.php [QSA]

这篇关于在HTML中的PHP文件不运行或者被注释掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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