PHP代码高亮
<?php
// 检查是否有表单提交
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 获取用户输入的名字
$name = htmlspecialchars($_POST['name']);
} else {
$name = "";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple PHP Page</title>
</head>
<body>
<h1>Welcome to My PHP Page</h1>
<p>Current Time: <?php echo date('Y-m-d H:i:s'); ?></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<label for="name">Enter your name:</label>
<input type="text" id="name" name="name" value="<?php echo $name; ?>">
<input type="submit" value="Submit">
</form>
<?php
if (!empty($name)) {
echo "<p>Welcome, $name!</p>";
}
?>
</body>
</html>
哈哈哈哈哈