3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a = 'This is $a from A'; public $b = 'This is $b from A'; public function __sleep(): array { var_dump(array_keys(get_object_vars($this))); return []; } } class B extends A { public $a = 'This is $a from B'; } $b = new B; serialize($b);
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14, 8.4.1
array(2) { [0]=> string(1) "a" [1]=> string(1) "b" }
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
array(2) { [0]=> string(1) "b" [1]=> string(1) "a" }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33
array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "a" }

preferences:
65.23 ms | 409 KiB | 5 Q