3 ms·
I think that in that case it should return false instead of 0 so (int)$val === false means that the variable is not a number. Right now I guess that the altern
by baisq 4y ago
I think that in that case it should return false instead of 0 so (int)$val === false means that the variable is not a number.
Right now I guess that the alternative is using is_numeric and then casting to int if possible.
- Y-bar 4y agoBut the forced cast to integer is always guaranteed to result in an integer. So why would it make more sense to explicitly force cast a variable's type to an integer and get a boolean as the functions return value? Edit: > (int)$val === false Would always be false because comparing two types, an integer and boolean would always be false.