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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -