我对编程很陌生,已经吸收了大约 150 页的书。当下面的代码让我很难受时,我对 PHP 的操作很顺利。谁能解释一下打开和关闭 PHP 标记的位置。
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "<p>Thanks for Registering</p>",
"Username: ", htmlentities ($_POST['username']), "<br />",
"Email: ", htmlentities ($_POST['email']), "<br />";
}
else { ?>
<form action = "test.php" method = "post">
<label for = "username">Username: </label>
<input type = "text" name = "username" />
<label for = "email">Email: </label>
<input type = "text" name = "email" />
<input type = "submit" value = "Register" />
</form>
<?php }
?>
我想,应该只有一对 PHP 标签:
<?php
上面代码开头的开始标签?>
上述代码结束时的结束标签
其他任何事情我都很难消化,请帮助我理解为什么 php 标签存在于代码之间非常奇怪的位置。谢谢