I’m studying PHP and web forms and would like some clarity on what’s happening here with IF/TRUE statements.
In the below sample, if someone submits their email address it is stored in $email? which will then evaluate as TRUE. Is their email address (the stored value in $email) now being overwritten by the word TRUE?
[CODE]// Check for an email address.
if (strlen($_POST[’email’]) > 0) {
$email = TRUE;
} else {
$email = FALSE;
echo ‘<p>You forgot to enter your email address!</p>’;
}[/CODE]
At the end of the IF statements, there is the ($name && $email && etc) stuff where there is no else after it. Is it looking to see if TRUE is flagged to all of these?
[CODE]if ($name && $email && $username && $password) { // If everything’s okay.
// Register the user.
echo ‘<p>You are now registered.</p>’;
} else { // Something’s not TRUE.
echo ‘<p>Please go back and try again.</p>’;
}[/CODE]
Also, sometimes I just see “if ($var);” then straight on to something else without an interrogative. What is happening with these? I gather there’s a truth test but what passes as true if there seems to be no specific test accociated with it? Some clarity on these issue would help me understand what underlies these type of IFs