php - 如何在 HTML 中运行 PHP?

标签 php html embed embedding

如果我在与 index.html 相同的目录中有一个文件 file.php:

文件.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 中?

最佳答案

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

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

关于php - 如何在 HTML 中运行 PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6324098/

相关文章:

javascript - magento 1.7 自定义选项不更新价格

css - 如何为 div 组件添加一个特殊的 CSS 类以仅在 IE 上运行?

javascript - 如果外部加载元素,jQuery 将无法工作

javascript - 如何缩小嵌入式谷歌地图?

html - YouTube 嵌入视频播放器尺寸仍然太小

php - 从 php 数据库中获取一组 JSON 数据

php - 找不到存储过程中的错误

php - 正确参数化 mysqli 查询并打印多行

javascript - 大写与小写

jQuery - 多个音频元素和音量控制