要在用户登录时显示表单,最好将其存储在变量中并回显吗?
选项1
<?php $form = "<div><form id=\"login\"></form></div>"; ?>
<html>
<?php
if (!isset($_SESSION['username']))
{
echo $form;
}
else {
echo"<li><a href=\"logout.php\">Sign Out</a></li>";
} ?>
</html>
或点击进出php?
选项 2
<?php if (!isset($_SESSION['username']))
{?>
<div><form id=\"login\"></form><div>
<?php }
else
{ ?>
<li><a href="logout.php">Sign Out</a></li>
}?>