PHP - Logical negation: !
The logical negation operator is used to determine the oposite value. in our case: if input is true then output is false, and if input is false the result is true. In next table you can find all possibilities:a | x |
---|---|
False | True |
True | False |
!
Description
! par1
Input
- par1 - Logical value
Output
- Result - Logical value
Examples
PHP
In the source code you can find the equivalent of the above table, for easier orientation at the end of each line is a comment which shows the result.$a1 = !false; // a1 = true
$a2 = !true; // a2 = false
PHP
Even one example in what situations we can use the operation logical negation:!$a
!$b && true
!(10 >$a || $a<5)
PHP
Other pieces of example codes:!$a
You can find it in the following collections: logical operators
Logical negation in another programming language:
Differences to: