6. PHP Logical Operators:-
PHP Logical Operators का Use दो condition statements को जोड़ने के लिए किया जाता है
Operator |
Name |
Example |
Result |
and |
And |
$x and $y |
True if both $x and $y are true |
or |
Or |
$x or $y |
True if either $x or $y is true |
xor |
Xor |
$x xor $y |
True if either $x or $y is true, but not both |
&& |
And |
$x && $y |
True if both $x and $y are true |
|| |
Or |
$x || $y |
True if either $$x or $y is true |
! |
Not |
!$x |
True if $x is not true |
And operator :-And operator का use दो condition को check करने के लिए किया जाता है यदि दोनों Condition true होती है तो ही Output True आता है But यदि एक भी condition false हो जाती है तो output False आ जाता है

Figure:-1 PHP logical and Operator
Or operator :-Or operator का use दो condition को check करने के लिए किया जाता है यदि एक condition या दोनों Condition true होती है तो ही Output True आता है । इसमे Output False तभी आता है जब दोनों condition false हो ।

Figure:-2 PHP logical or Operator
उपरोक्त program को किसी भी browser पर run करने पर तथा निम्न output show होता है।

Figure:-2 PHP logical or Operator
Xor operator :-Xor operator का use दो condition को check करने के लिए किया जाता है । जब दोनों condition मे से केवल एक condition true हो तभी यह operator output true देता है otherwise false return करता है

Figure:-2 PHP logical xor Operator
&& operator :-&& operator का use दो condition को check करने के लिए किया जाता है यदि दोनों Condition true होती है तो ही Output True आता है But यदि एक भी condition false हो जाती है तो output False आ जाता है

Figure:-2 PHP logical && Operator
|| operator :-|| operator का use दो condition को check करने के लिए किया जाता है यदि एक condition या दोनों Condition true होती है तो ही Output True आता है । इसमे Output False तभी आता है जब दोनों condition false हो ।

Figure:-2 PHP logical || Operator
Not( ! ) operator :-Not( ! ) operator का use केवल एक condition को चेक करने के लिए किया जाता है यदि condition true है तो output false आता है और यदि condition false है तो output true आता है अर्थात condition के opposite output आता है । ।

Figure:-2 PHP logical Not (!) Operator