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?

2
  • 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 Commented Aug 15, 2017 at 20:46
  • Possible duplicate of PHP - How object serialize/unserialize works? Commented Aug 15, 2017 at 21:07

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.