对象相等php,php – 为什么这两个对象是相等的(==)?

PHP中我有两个对象,它们是不同的,因为$_frets变量(x是一个字符串“x”),但PHP说

($o1 == $o2) == TRUE.

为什么?

$o1的转储:

guitarChord Object

(

[_guitarChord:guitarChord:private] =>

[_chord:guitarChord:private] => chord Object()

[_baseFret:guitarChord:private] => 0

[_frets:guitarChord:private] => Array

(

[0] => x

[1] => 0

[2] => 2

[3] => 2

[4] => 2

[5] => x

)

[_tuning:guitarChord:private] => tuning Object()

[currVariation] => 0

[nextVariation] =>

[prevVariation] =>

)

$o2的转储:

guitarChord Object

(

[_guitarChord:guitarChord:private] =>

[_chord:guitarChord:private] => chord Object()

[_baseFret:guitarChord:private] => 0

[_frets:guitarChord:private] => Array

(

[0] => x

[1] => 0

[2] => 2

[3] => 2

[4] => 2

[5] => 0

)

[_tuning:guitarChord:private] => tuning Object()

[currVariation] => 0

[nextVariation] =>

[prevVariation] =>

)

编辑:

所以原因是因为(“x”== 0)= TRUE.谁能告诉我为什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值