2.1 If statement
'If ' statement is the most
common used statement to compare values. For example
if ($a
> $b) {
print "a is bigger than b";
} |
2.2 ELSE
Often you'd want to execute a statement if a certain condition
is met, and a different statement if the condition is
not met. This is what else is for. else extends an if
statement to execute a statement in case the expression
in the if statement evaluates to FALSE. For example, the
following code would display a is bigger than b if $a
is bigger than $b, and a is NOT bigger than b otherwise:
if ($a > $b) {
print "a is bigger than b";
} else {
print "a is NOT bigger than b";
} |
More
You can also check for multiple tests in one IF statement.
For instance, if you have a form and you want to check
if any of the fields were left blank you could use:
if ($name == ""
|| $password == "" || $addressl == ""
) {
echo "Please fill in all the fields";
} |
Part
3 While loop and array
Locating An PHP Web Hosting Provider:
iPowerWeb.com
is one of the best choice for PHP web hosting. It has
all of the basic components needed for operating most
websites. And they did it at $7.95 per month.