Home Tutorial Php Phpbeginners Logical Operators

 
 

Logical Operators
Posted on: February 4, 2011 at 12:00 AM
Advertisement
This section contains the detail about Logical operator in PHP.

Logical Operators

Operator is used to perform operation on variable and values. Logical operators perform logical operation which produce Boolean result i.e. True or False.

Given below the some of the main operators of PHP :

OPERATOR NAME EXAMPLE
&& And a=7
b=6
(a< 12 && b> 3) returns true
|| Or a=3
b=9
(x==4 || y==4) returns false
! Not x=3 y=4
!(x==y) returns true

The below example with output given you a clear idea :

Example :

<?php
$a=3;
$b=21;
$c=30;

echo !($a=$b) ? "true\n" : "false\n";
echo "<br/>";
echo !($b>$c) ? "true\n" : "false\n";
echo "<br/>";
echo !($c>$a) ? "true\n" : "false\n";

?>

Output :

false
true
false

Advertisement

Related Tags for Logical Operators:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 4, 2011

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com