Php IF & ELSE Statemments
Php if, else statements in PHP can perform different actions, based on different conditions.
That means, sometimes you may want to show "bye, have a nice day" instead of "hello how are you?" in user's browser.
syntax :
if (condition)Example :
Code.....
else
Code.....
$val = 1;
If ($val == 1)
echo "value is one";
else
echo "value is not one";
PHP IF & ELSEIF Statements.
Php elseif Statements is same as elseif statements. But this time you can extend the limit of your conditions.
Syntax :
if (condition)Code :
code ...
elseif (condition)
code ...
elseif (condition)
code...
else
If ($val = 1)Output of above code is :
echo "value is one";
elseif ($val == 2)
echo "value is two";
elseif ($val == 3)
echo "value is three";
else
echo "value is unknown";
value is three