Logical Expression in PHP

        Today, we will talk about logical expression in PHP.
Syntax of the Logical expression are same as the other Programming languages i.e. C and java.
Syntax:
if Condition:
 if(condition)
 run this
if else Condition:
 if(condition)
 run this
else
run this
nested if else Condition:
 if(condition)
 run this
else if
 run this
else
run this


############################
PHP Code

############################
<?php
$a = 4;
$b = 5;

// if condition
if( $a > $b ) // if no curly braces is used, then only next line will be executed 
echo " <br/> a is  greater then b ";
echo " <br/> this will not depend on the condition ";
echo " <hr/> ";
if( $a < $b )  
echo " <br/> a is  less then b ";
echo " <br/> this will not depend on the condition ";
echo " <hr/> ";
if( $a > $b ) // if curly braces is used, then next line will also depend on condition 
{
echo " <br/> a is  greater then b";
echo " <br/> this will also depend on the condition ";
echo " <br/> this will also depend on the condition ";
}
echo " <hr/> ";

if( $a < $b )
{
echo " <br/> a is  less then b ";
echo " <br/> this will also depend on the condition ";
echo " <br/> this will also depend on the condition ";
}

echo " <hr/> ";

// if else condition
if  (  $a > $b )
{
echo " <br/> A is Greator then B ";
}
else 
{
echo " <br/> A is not Greator then B ";
}
?>



############################

Comments

Popular posts from this blog

Page Unload Show Notification to user

Function Oriented File Upload PHP

Upload File Using PHP - Example For Image