$areSame = (serialize($ob1) === serialize($ob2));
This easy way of comparing two objects in php.It will take in account object variables.
Example :
class ob1{ public $number = 1; } class ob2{ public $number = 1; } $areSame = serialize(new ob1()) === serialize(new ob2()) //$areSame = true; class ob1{ public $number = 1; } class ob2{ public $number = 2; } $areSame = serialize(new ob1()) === serialize(new ob2()) //$areSame = false;
Suggestions or problems ?
Write a comment.