3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ private $foo = 10; } class B extends A{ private $foo = 20; } var_dump(new B); class C{ private $foo = 10; } class D extends C{ private $foo = 20; function __debugInfo(){ $g = (array)$this; $g['moar'] = 1111; return $g; } } var_dump(new D);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
object(B)#1 (2) { ["foo":"A":private]=> int(10) ["foo":"B":private]=> int(20) } object(D)#1 (3) { ["foo":"C":private]=> int(10) ["foo":"D":private]=> int(20) ["moar"]=> int(1111) }
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
object(B)#1 (2) { ["foo":"B":private]=> int(20) ["foo":"A":private]=> int(10) } object(D)#1 (3) { ["foo":"D":private]=> int(20) ["foo":"C":private]=> int(10) ["moar"]=> int(1111) }
Output for 5.5.0 - 5.5.35
object(B)#1 (2) { ["foo":"B":private]=> int(20) ["foo":"A":private]=> int(10) } object(D)#1 (2) { ["foo":"D":private]=> int(20) ["foo":"C":private]=> int(10) }

preferences:
100.52 ms | 1727 KiB | 4 Q