Objects comparison in PHP

前端 未结 3 340
小蘑菇
小蘑菇 2021-01-13 13:55

SO,

The problem

It\'s not well-known, but PHP allows to compare objects - and not just on equality == - but on <

3条回答
  •  一生所求
    2021-01-13 14:25

    PHP compares sequentially (in the order of declaration) the object properties and stops at the first inequal property found. This behavior is not documented, so there's not much to be said about it, sadly, other than looking at the source of PHP.

    Not documented is usually a synonym of "don't rely on it".

提交回复
热议问题