|
if" statement, which as its name implies does
something if a given condition is true.
$name = "peter";
if($name == "peter")
{
print "Hello peter how are you today?\n";
}
else
{
print "Sorry I don't know you\n";
}
if" statement which says
'if the variable called name holds a value that is equal to
peter then perform the program lines in the first set of curly
brackets, otherwise perform the commands in the second set of
brackets'
if' understands:
- == - Are variables equal ( $A == $B )
- != - Are variables NOT equal ( $A != $B )
- >= - Is variable 1 greater than or equal to variable 2 ( $A >= $B )
- <= - Is variable 1 less than or equal to variable 2 ( $A <= $B )
- > - Is variable 1 greater than variable 2 ( $A > $B )
- < - Is variable 1 less than variable 2 ( $A < $B )
- && - AND (Both decisions must be true)
- || - OR (Either of the decisions must be true)
$fname = "peter";
$lname = "shaw";
if( ($fname == "peter") && ($lname == "shaw") )
{
print "greetings Shawty, you are allowed in…";
}
else
{
print "be-gone stranger, you are banished from here…";
}
fname must be equal to
"peter" AND lname must be equal to "shaw" before I
allow the top code to run, if not then the bottom code will run.
| Comments: | ||
No Messages FoundYou can post questions/corrections/feedback here
| ||
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


