Php IF & ELSE

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)
Code.....
else
Code.....
Example :

$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 ...
elseif (condition)
code ...
elseif (condition)
code...
else
Code :

If ($val = 1)

echo "value is one";
elseif ($val == 2)
echo "value is two";
elseif ($val == 3)
echo "value is three";
else
echo "value is unknown";
Output of above code is :

value is three