PHP Logical Operators - PHP Tutorial 28

Published: 03 September 2019
on channel: ChidresTechTutorials
1,506
20

Notes for You:: PHP Logical Operators - PHP Tutorial 28
- are also known as logical connectives.
- are used to connect one or more conditions.
- accept Boolean operands, on evaluation they yield the result true or false.

&& / and: Logical and Operator:
- If both LHS and RHS operands are true then the result will be true, in all other cases the result will be false.

|| / or: Logical or Operator:
- If both LHS and RHS operands are false then the result will be false, in all other cases the result will be true.

xor : Logical exclusive Or Operator:
- If both are same then the result will be false otherwise true.

!: Logical not Operator:
- If the given operand is false, then the result will be true. Vice versa.

Example code:
echo (true && true) ? "true" : "false", "<br/>"; // true
echo (true && false) ? "true" : "false", "<br/>"; // false
echo (false && true) ? "true" : "false", "<br/>"; // false
echo (false && false) ? "true" : "false", "<br/>"; // false
echo "<br/>";
echo (true || true) ? "true" : "false", "<br/>"; // true
echo (true || false) ? "true" : "false", "<br/>"; // true
echo (false || true) ? "true" : "false", "<br/>"; // true
echo (false || false) ? "true" : "false", "<br/>"; // false
echo "<br/>";
echo (true xor true) ? "true" : "false", "<br/>"; // false
echo (true xor false) ? "true" : "false", "<br/>"; // true
echo (false xor true) ? "true" : "false", "<br/>"; // true
echo (false xor false) ? "true" : "false", "<br/>"; // false
echo "<br/>";
echo (!true) ? "true" : "false","<br/>"; // false
echo (!false) ? "true" : "false","<br/>"; // true
echo "<br/>";

echo ((3<4) && (4<5)) ? "true" : "false","<br/>"; // true
echo ((3<4) and (4<5)) ? "true" : "false","<br/>"; // true
echo "<br/>";
echo ((3>4) || (4>5)) ? "true" : "false","<br/>"; // false
echo ((3>4) or (4>5)) ? "true" : "false","<br/>"; // false
echo "<br/>";
echo (!(3<4)) ? "true" : "false","<br/>"; // false

Note:
- replace < with less-than symbol.
- replace > with greater-than symbol.

=========================================

Follow the link for next video:
PHP Tutorial 29 - Conditional Operator in PHP | PHP Ternary Operator Tutorial
   • PHP Conditional Operator - PHP Tutori...  

Follow the link for previous video:
PHP Tutorial 27 - Relational Operators in PHP | PHP Comparison Operators Tutorial
   • PHP Relational Operators - PHP Tutori...  

=========================================

PHP Tutorials Playlist:-
   • PHP Tutorials  

=========================================
Watch My Other Useful Tutorials:-

MySQL Tutorials Playlist:-
   • MySQL Tutorials  

HTML Tutorials Playlist:-
   • HTML Tutorials  

CSS Tutorials Playlist:-
   • CSS Tutorials  

JavaScript Tutorials Playlist:-
   • JavaScript Tutorials  

=========================================

Subscribe to our YouTube channel:
   / chidrestechtutorials  

Visit our Website:
https://www.chidrestechtutorials.com

=========================================
Hash Tags:
#PHP #PHPTutorial #ChidresTechTutorials


On this page of the site you can watch the video online PHP Logical Operators - PHP Tutorial 28 with a duration of hours minute second in good quality, which was uploaded by the user ChidresTechTutorials 03 September 2019, share the link with friends and acquaintances, this video has already been watched 1,506 times on youtube and it was liked by 20 viewers. Enjoy your viewing!