I've recently had a bug that was perplexing me.... traced it down to the following (simplified) statmement, which provides a real example
function test_it($team)
{ echo (($team=="a") ? "Yep it is!" : "No Way");
}
So, if I execute test_it(0); I get the result "Yep it is!" ??
The logic of the statement looks fine, but obviously to get a correct outcome I needed to make it "==="....
Can anyone explain why this is the case? Just to help me understand why/what I should avoid in future.
Its because of the string / char of a i.e "a" and passing through 0 .
the === operator performs a 'typesafe comparison'
Explanation and question here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With