Given two classes:
class A
{
private $prop1;
}
class B extends A
{
private $prop2;
public function __sleep()
{
return array('prop1','prop2');
}
}
That will only serialize the value of prop2 as it’s a direct property of class B.
How can I get it to output the inherited prop1 from superclass A?
EDIT:
Not defining the __sleep() will show the private properties in the serialized string without setting them to protected. They look something like �A�prop1, only I cannot get what the � is.
Explicitly call the parent class’s function and append the result: