if ()
could be read as:
if (comparison of two values)
do operation;
Take the following example.
int $a = 15;the if statement checks to see if $a is larger than $b if the comparison is true. We change the value of $c. Note: if you have one operation after the comparison then you do not need the curly brackets {}.
int $b = 6;
int $c = 0;
if ($a > $b)
{$c = $a - $b;}
print $c;
if you wanted to add in an option if the condition fails you could use the else command.
int $a = 15;
int $b = 6;
int $c = 0;
if ($a > $b)
{$c = $a - $b;}
else
{$c = $a * $b;}
print $c;
<Top>