Martynas
Martynas

Reputation: 43

Can someone explain php comparison oddities

Why this php code evals to true? Was thinking maybe some kind of casting, but can't find any related info. Any ideas?

var_dump(5 < [6]);

Upvotes: 0

Views: 175

Answers (1)

rsm
rsm

Reputation: 2560

In php documentation on comparison operator http://php.net/manual/en/language.operators.comparison.php, in chapter Comparison with Various Types:

array | anything | array is always greater

So, there is no casting. It's sort of hard-coded.

Upvotes: 3

Related Questions