php - Typecasting a boolean operation to a boolean results in false -
in php, when typecasting boolean operation returns true, reason interpreter typecast false. why this? take following example:
(bool) 1 === 1 // false (bool) (1 === 1) // true this operation should return true, reason returns false. when adding parentheses work correctly. explain why is? i'm using php 7.0.8
it's order of operations. first statement evaluates bool before equality check
(bool) 1 === 1 same ((bool) 1) === 1 whereas
(bool) (1 === 1) evaluates inside of parenthesis first.
1 isn't same thing true.
Comments
Post a Comment