I'll post a question and I hope the administrators stackoverflow do not put this as a duplicate topic , because I find no explanation for such a thing .
All we know that after the type- juggling this comparison looks like this:
false == array() -> (bool) == false (bool) array() -> false == false -> true
So far, nothing unusual.
The problem was trying to ask for an explanation for such a thing but the answers did not have senses and then it seemed that the topic was duplicated , but actually it is not a duplicate topic.
The question was how the php interprets this comparison below:
'' == array()
Some people said:
"A cast is done to the empty string to array"
The result is: (array) '' == array() -> array('') == array() -> false
Seems to be right.
But the big problem is here, below:
'' == array('')
Because it does not return true ? If by some theory:
'' == array('') -> This should return true
'' == array('') -> (array)'' == array('') -> array('') == array('')
But false is returned.
Can you explain once and for all this issue ?
var_dump(array() > "");, but an apple no bagsvar_dump("" > array());And anarray("")even contains a stringvar_dump(array("") > "");like a bag with an apple :D