如何在 HTML 中运行 PHP?

发布于 2024-11-15 02:47:42 字数 402 浏览 5 评论 0原文

如果我有一个文件 file.php 与 index.html 位于同一目录中:

file.php:

<?php
echo "<body><img src=\"hi.jpg\" /><br /><p>I was here</p>"
?>

index.html:

<html>
<head></head>
<!-- I want to enter the PHP in file.php here --></body>
</html>

如何将 file.php 放入 index.html 中?

If I have a file, file.php, in the same directory as index.html:

file.php:

<?php
echo "<body><img src=\"hi.jpg\" /><br /><p>I was here</p>"
?>

index.html:

<html>
<head></head>
<!-- I want to enter the PHP in file.php here --></body>
</html>

How do I put file.php in index.html?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此生挚爱伱 2024-11-22 02:47:42

index.html 重命名为 index.php,并填充以下内容:

<html>
<head></head>
<?php
require('./file.php');
?>
</html>

Rename index.html to index.php, and fill it with the following:

<html>
<head></head>
<?php
require('./file.php');
?>
</html>
你在我安 2024-11-22 02:47:42

这对我有用:

将以下内容添加到您的 .htaccess 文件

AddType application/x-httpd-php .php .htm .html
AddHandler application/x-httpd-php5 .html .php .htm

This worked for me:

Add the following to your .htaccess file

AddType application/x-httpd-php .php .htm .html
AddHandler application/x-httpd-php5 .html .php .htm
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文