Comparing Objects in PHP4
=> We can compare two objects with == operator.
=> == operator return true if properties of the objects are same.
Example:
class One {
var $val;
function One($var){
$this->var = $var;
}
}
$objl = new One('num');
$obj2 = new One('num');
$obj3 = new One('num1');
if($objl == $obj2)
echo "Same";
else
echo "Diiferent";
if($objl == $obj3)
echo "Same";
else
echo "Diiferent";
In the above example
if($objl == $obj2) - returns true
because both having the same value for variable $val.
if($objl == $obj3) - returns false
because both having the different values for variable $val.
