Regardless of what is in the variable, it is converted to a logical value (the variable itself, of course, remains intact), and then the NOT ( ! ) Operation is performed as a result of the Boolean. The conversion will happen because ! is a logical operator and works only with boolean values.
When converting to boolean, the following values ββare considered FALSE:
- logical false itself
- integer 0 (zero)
- float 0.0 (zero)
- empty string and string "0"
- array with zero elements
- object with null member variables (PHP 4 only)
- special type NULL (including undefined variables)
- SimpleXML objects created from empty tags
Tip. If the variable does not have to be logical, you can use something more specific, for example isset($variable) , empty($variable) , $variable === '' , etc. depending on what you want to check. See the manual for more details.
source share