LearnerId:

Php Programming


Content List

Skip Navigation Links.
Collapse Total Week Wise ContentTotal Week Wise Content
Collapse Week1Week1
Collapse Week2Week2
Collapse Week3Week3
Collapse Week4Week4
Collapse Week5 : DataBaseWeek5 : DataBase
Collapse Week6:Week6:
Collapse Week 7: ProjectWeek 7: Project

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 आ जाता है

Example


Figure:-1 PHP logical and Operator

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

Example


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 करता है

Example


Figure:-2 PHP logical xor Operator

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

Example


Figure:-2 PHP logical && Operator

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

Example


Figure:-2 PHP logical || Operator

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

Example


Figure:-2 PHP logical Not (!) Operator





left right