What does the double not operator do in PHP?
For example:
return !! $row;
What would the code above do?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not the “double not operator”, it’s the not operator applied twice. The right
!will result in a boolean, regardless of the operand. Then the left!will negate that boolean.This means that for any true value (numbers other than zero, non-empty strings and arrays, etc.) you will get the boolean value
TRUE, and for any false value (0, 0.0,NULL, empty strings or empty arrays) you will get the boolean valueFALSE.It is functionally equivalent to a cast to
boolean: