|
|
PHP If Else Conditional Statement
|
Tutorials » Php »
|
Topic |
What is If Else statement?
|
|
Explanation |
|
The conditional statement "else" is used as extension of "if" statement. If the condition fails then it executes
another statements under the "else" condition.
Syntax
if (expr)
{Statements}//true
else
{Statements}//false
Based on the result of expressions, the statements are executed.
Example
<?php
$c = 10;
$d = 20;
if ($c > $d)
{echo "C is bigger than d";}
else
{echo "D is bigger than c";}
?>
Result:
D is bigger than C
In the above example in the if the condition "$c>$d" is true then the message "C is bigger than D"
is displayed, else the message "D is bigger than C" is displayed.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|