|
|
 |
|
|
|
|
|
Assuming you know how to use variable see Tutorial
<?php $myVar = "test"; $myVar2 = 15;
if ($myVar == "test") {
if ($myVar2 > 10) { print( "myVar equals test and myVar2 is greater than 10"); } }
else { print ("myVar doesn't equal test and i don't know anything about myVar2"); ?>
if (condition) { // code if condition is true } else { // code if condition is false }
don't forget { } as they delimit the block concerned by any of the two branch. the else part is optionnal and you can ommit it as i do in the second if.
condition can compare anything you want as long it is logic. the operator are equal: == greater: > greater or equal: >= lower: < lower or equal <= you can use word "or" and "and" if you want to make more complex condition as: ($myVar == "test") or ($myVar2 > 15)
if you think it could be better tell me, it's the really first time i make a tutorial and i think i could be too technical.
regards, sébastien
|
|
|
|