Skip to main content
3 of 3
from 4361553 - to 14859163,4361553
miken32
  • 42.5k
  • 16
  • 127
  • 177

PHP Serialization and Inheritance

Not sure what the process is for serializing a child class that is implementing the Serializable interface, the parent class no longer retains the data it was once serializing. Is there a step I am missing?

class A { private $aVar = "test"; } class B extends A implements Serializable { private static $bVar = "tset"; public function serialize() { return serialize(self::$bVar); } public function unserialize($serialized) { self::$bVar = unserialize($serialized); } } $s = serialize(new B()); $u = unserialize($s); 
NueFox
  • 351
  • 1
  • 4
  • 14