1

I serialized an object of PHP class in Laravel. Afterwards, I changed the class definition adding a new method and when I unserialize the old object and make a call to that newly implemented method, it works.

I wonder why and how?

Oscar
  • 123
  • 6
  • 3
    Look at a serialized class intance, and you'll see that it contains only the class name and the property values, not the code – Mark Baker Aug 15 '17 at 20:46
  • Possible duplicate of [PHP - How object serialize/unserialize works?](https://stackoverflow.com/questions/7873395/php-how-object-serialize-unserialize-works) – Don't Panic Aug 15 '17 at 21:07

1 Answers1

4

Because serialization process keeps only state of the objects (fields) but not your methods with implementation.