filmov
tv
PHP Logical Operators - PHP Tutorial 28
![preview_player](https://i.ytimg.com/vi/Mhe8A_Em-sU/maxresdefault.jpg)
Показать описание
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
Follow the link for previous video:
PHP Tutorial 27 - Relational Operators in PHP | PHP Comparison Operators Tutorial
=========================================
PHP Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
HTML Tutorials Playlist:-
CSS Tutorials Playlist:-
JavaScript Tutorials Playlist:-
=========================================
Subscribe to our YouTube channel:
Visit our Website:
=========================================
Hash Tags:
#PHP #PHPTutorial #ChidresTechTutorials
- 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
Follow the link for previous video:
PHP Tutorial 27 - Relational Operators in PHP | PHP Comparison Operators Tutorial
=========================================
PHP Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
MySQL Tutorials Playlist:-
HTML Tutorials Playlist:-
CSS Tutorials Playlist:-
JavaScript Tutorials Playlist:-
=========================================
Subscribe to our YouTube channel:
Visit our Website:
=========================================
Hash Tags:
#PHP #PHPTutorial #ChidresTechTutorials
Комментарии