The “NOT NOT” operator or Double not(!!) operator in PHP simply returns the truth value of the variable or expression. To explain in very simple terms, the first not operator(!) negates the expression. The second not operator(!) again negates the expression resulting the true value which was present before.
The (!!) operator returns as that Boolean function. If use !! to an expression the true value will be true and false value would be false. That is no change in the Boolean value. By using this double not(!!) operator it can increase the code readability and also ensure the truth and false values to be strictly Boolean data types.
Difference between logical NOT(!) operator and Double NOT(!!) operator in PHP: The Not operator is the mathematically complements or negates the Boolean value of the concerned data. For example a Boolean value of $a = True, then the NOT operator imposed on it !$a would be False. This is about logical NOT or Negation operator. Where as the Double NOT (!!) operator returns only the Boolean cast or the truth value. That is !!$a is always TRUE.
Here is an another example based on double NOT operator.
The above code strictly save the Boolean data type and returns the truth value of the variable.
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Ternary operator vs Null coalescing operator in PHP
- Double Layered Text Effect using CSS
- Convert String to Double in Java
- Convert Double to Integer in Java
- Double Brace Initialization in Java
- What is the use of a double-click event in AngularJs?
- Modulus of two float or double numbers
- Solutions to prevent Double-Spending of Bitcoins
- How to print string with double quotes in Golang?
- 'AND' vs '&&' as operator in PHP
- PHP | $ vs $$ operator
- set operator= in C++ STL
- || operator in Java
- PHP | Ternary Operator
- unordered_multiset operator = in C++ STL
- unordered_set operator= in C++ STL
- unordered_set == operator in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.