08 January 2011

Php For Beginners (Lesson 4d)

If you are reading this lesson then I assume that you have read all of my previous lessons, so coming directly to the point, I will be discussing logical operators and their usage in php.

And Operator (&&)
"&&" operator is used to take the union of two or more conditions and returns true if and only if all the conditions are true.
<?php
$a=5;
$b=6;
if ($a==5 && $b==6)
    echo "true"; //Outputs true
?>
Or Operator (||)
"||" operator returns true if any of the condition is true.
<?php
$a=5;
$b=6;
if ($a==5 || $b==5)
   echo "true"; //Outputs true 
?>
Not Operator (!)
"!" operator returns true when no condition is true.
<?php
$a=5;
$b=6;
if !($a==$b)
   echo "true"; //Outputs true
?> 
Well that is all we need to know about Operators in php, keep reading and feel free to ask questions through comments.


next Previous Lesson --- Next Lesson next

No comments: