如何在 HTML 文件中运行 PHP 脚本?
如何在.html文件中运行简单的PHP代码?
在“html”或“htm”中执行“php”代码,用于“apache版本2.4.23”
转到 '/etc/apache2/mods-enabled' 编辑 '@mime.conf'
转到文件末尾并添加以下行:
"AddType application/x-httpd-php .html .htm"
BEFORE 标签 '< /ifModules >' 在 'debian' 下使用 'apache 2.4.23' 和 'php 5.6.17-1' 进行验证和测试
您不能在以 结尾的 html 页面中运行 PHP
。除非页面实际上是 PHP,并且扩展名更改为 从 到.html
.htaccess
.php
.html
您的意思是:
index.html
<html>
...
<?php echo "Hello world";?> //This is impossible
index.php //The file extension can be changed using htaccess, ex: its type stays php but will be visible to visitors as index.html
<?php echo "Hello world";?>