Comparing objects--对象比较

Comparing objects 对象比较  

 

         In PHP 5, object comparison is more complicated than in PHP 4 and more in accordance to what one will expect from an Object Oriented Language (not that PHP 5 is such a language).        

         在php5中,对象比较会比在php4中更加复杂,更加像面向对象语言(这倒不是说php5不是面对对象语言)

         When using the comparison operator (== ), object variables are compared in a simple manner, namely: Two object instances are equal if they have the same attributes and values, and are instances of the same class.

          当用(==)比较两个对象的时候,比较的方法是非常简单的,也就是说:当两个对象实例具有相同的属性和值,并且是同一个类的实例,那么他们就相等。

         On the other hand, when using the identity operator (=== ), object variables are identical if and only if they refer to the same instance of the same class.

           在另一方面,当我们用恒等运算符(===),如果两个比较的对象是同一个类的的同一个实例那么这两个对象恒等。

           An example will clarify these rules.

 

           下面这个例子会说明这些规则。

           

 

 

            上例将输出:

           

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值