<?php ?>
標簽來嵌入PHP代碼,實現動態生成內容,例如:<!DOCTYPE html>
<html>
<head>
<title>PHP與HTML5結合示例</title>
</head>
<body>
<h1><?php echo "Hello, World!"; ?></h1>
</body>
</html>
<?php
echo "<!DOCTYPE html>";
echo "<html>";
echo "<head>";
echo "<title>PHP與HTML5結合示例</title>";
echo "</head>";
echo "<body>";
echo "<h1>Hello, World!</h1>";
echo "</body>";
echo "</html>";
?>
include
語句來引入HTML文件,實現代碼的模塊化和復用,例如:<?php
include 'header.html';
echo "<h1>Hello, World!</h1>";
include 'footer.html';
?>
echo
函數輸出HTML標簽,實現動態生成HTML內容,例如:<?php
echo "<h1>Hello, World!</h1>";
?>