1

I have a simple class:

class obj__image extends obj__file {

    public $dimensions;
    public $storedDPI;
    public $colorProfile;

}

When i store an instance of this to my session (for example), the object gets serialized and stored away. That's fine.

But is there any way to define a class variable, such as the above $colorProfile so that it will not be stored when storing/serializing the object?

1 Answer 1

2

You can control exactly which properties are included in a serialized object by defining a magic __sleep() method for the class. The __sleep() method should return an array of property names: those property names listed in the array will be included in the serialized object, any other unlisted properties will be discarded

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.