【发布时间】:2018-08-12 06:55:35
【问题描述】:
我是 PHP 初学者,我试图在 HTML 文件中运行 php 代码。
HTML 文件
<!DOCTYPE html>
<html>
<head>
<title>Test Website - Php in HTML</title>
</head>
<body>
<h1>Testing php in html file</h1>
<p><?php echo "php text goes here..." ?></p>
</body>
</html>
.htaccess 文件
AddType application/x-httpd-php .htm .html
已经尝试过这里提到的步骤 --> Using .htaccess to make all .html pages to run as .php files?
请帮我在 html 文件中运行 php 代码。
【问题讨论】:
-
我不确定是否需要
RewriteRule ^(.*).html$ $1.php,因为无论如何这会将每个 .html 转换为 .php ...您的所有文件都需要在您的目录中以 .php 结尾。跨度> -
我无法将 html 扩展名(文件)转换为 PHP。我需要一个解决方案来运行 html 文件中的 PHP 代码。如果你能帮助我,请告诉我。
-
我不知道为什么人们反对我的问题。如果您没有解决方案,请告诉我,而不是对我的问题投反对票。