让我发布有问题的代码:
session_start(); // some text
$Var = "";
if (isset($_SESSION['id'])) {
// some conditions
$userid = $_SESSION['id'];
$username = $_SESSION['username'];
$var = some links or text here ;
}
else
{
$var = link or text here;
}
问题是:为什么首先$var="";
声明,然后再往下用在if
条件中。我想了解它的逻辑,为什么我可以这样写。
$var=header("Location: link.php");