Should I be casting as a boolean or fake a boolean?
php, syntax
Solution
Use the identical comparison operaton, which does not do any type juggling (and is faster).
if ($number !== 0) {
// ^^^
// Number is not identical to 0
}
Note: This is assuming the variable is actually a "integer variable", and not a string that happens to contain a number.
if (false == ($number === 0)) {
// ^^^
// It is false that Number is identical to 0
}
Problem
If I get an integer variable (anywhere from `0`+) There are a few things I can do to make sure the number is not `0`(zero): Option 1: ``` if($number > 0){ // number is not zero } ``` Option 2: ``` if($number){ // number is not zero } ``` Option 3: ``` if((bool) $number){ // number is not zero } ``` Option 4: ``` if(!!$number){ // number is not zero } ``` - Etcetera.... Which one of the above is considered really the best to do? Or is there an even better option?