Reputation: 5840
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?
Upvotes: 1
Views: 41
Reputation: 212452
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
Upvotes: 2