Why does the serialization?

Why the public_key property is not serilized?
I have serenitatis class B which extends class A
But the property public_key why it does not want sheralizoda, why does he have this behavior?
class A{
 private $public_key = ";

 protected function __construct($public_key)
 $this->public_key = $public_key;
 public function __sleep()
 return array('public_key');

class B extends A{
 public function __construct($public_key = 'hello')

$b = new B();

object(B)#1 (1) {
string(5) "hello"
PHP Notice: serialize(): "public_key" returned as member variable from __sleep() but does not exist in /home/master/test.php on line 24
object(B)#2 (2) {
string(0) ""
March 23rd 20 at 19:46
1 answer
March 23rd 20 at 19:48
Because you public_key private. Private properties and methods are not inherited, replace it with a protected

Find more questions by tags PHP