如何在HTML中运行PHP?

Dar*_*htA 4 html php embed embedding

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

file.php:

<?php
echo "<body><img src=\"hi.jpg\" /><br /><p>I was here</p>"
?>
Run Code Online (Sandbox Code Playgroud)

index.html的:

<html>
<head></head>
<!-- I want to enter the PHP in file.php here --></body>
</html>
Run Code Online (Sandbox Code Playgroud)

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

phi*_*hag 10

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

<html>
<head></head>
<?php
require('./file.php');
?>
</html>
Run Code Online (Sandbox Code Playgroud)