1

I was asked this interview question recently and I didn't know about this:

"Which PHP functions can be used to customize the serialization process of an object?"

Any sample implementation will be of great help to understand.

1 Answer 1

1

Clearly described in official documentation for Serializable interace - serialize and unserialize are the ones: http://php.net/manual/en/class.serializable.php

The old way is to implement methods __sleep and __wakeup which were supposed to remove references to runtime resources and reinitialize them respectively. This is not supported if the class implements Serializable mentioned earlier.

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

1 Comment

You can still use __sleep() and __wakeup(), they are not deprecated or removed as one may get the idea from your post. The Serializable interface just provides access to protected data.

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.