$foo = new StdClass();
$foo->this_is_false = 0;
echo ($foo->this_is_false == "Dog+Breath"); // 1?
Is this some VERY radical type coercion going on here?
Just php (and mysql). A loose comparison casts the string to a number and since the string doesn't start with any numerical characters, it ends up being a zero, which matches the assigned zero. You would need to use a strict === comparison for this to produce the expected result.
Hmm, apparently so ... how is it I've been doing this for 17 years and haven't encountered this before ... ? 😅
It's because you're adding string to an integer, so the string is cast to integer, and...
php > $foo = (integer) "Dog+Breath";
php > echo $foo;
PS: And the echo is casting the resulting Boolean true to a string value of "1".
php > $foo = true;
php > $bar = (string) $foo;
php > var_export($bar);