|
Wha is an if/else satement and when sould it be used? The if/else statement allows us to take an alternate path when the condition in if is false. Example: So if I go to to school is true then I arrive, but what if I don't go? Then that statement is false and I need a response for if the statement I made is not true so: else I stay home. PHP Code: $item_one = 1;
if ( $item_one== 1) { echo "True"; } else { echo "False"; }
Display: True
PHP Code: You can also add html to this code. $item_one = 1;
if ( $item_one== 1) { echo "<font color="green">True</font>"; } else { echo "<font color="red">False</font>"; }
Display: True
|