title: What's the fastest way to compare two objects in PHP?
body: <p>Let's say I have an object - a User object in this case - and I'd like to be able to track changes to with a separate class. The User object should not have to change it's behavior in any way for this to happen.</p>
  
  <p>Therefore, my separate class creates a "clean" copy of it, stores it somewhere locally, and then later can compare the User object to the original version to see if anything changed during its lifespan.</p>
  
  <p>Is there a function, a pattern, or anything that can quickly compare the two versions of the User object?</p>
  
  <p><strong>Option 1</strong>
  Maybe I could serialize each version, and directly compare, or hash them and compare?</p>
  
  <p><strong>Option 2</strong>
  Maybe I should simply create a ReflectionClass, run through each of the properties of the class and see if the two versions have the same property values?</p>
  
  <p><strong>Option 3</strong>
  Maybe there is a simple native function like <code>objects_are_equal($object1,$object2);</code>?</p>
  
  <p>What's the fastest way to do this?</p>