3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $property; } class B extends A { public $property; } $b = new B; $b->property = 'foo'; var_dump( $b ); $a = new A; $a->property = 'bar'; var_dump( $a );
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
object(B)#1 (1) { ["property"]=> string(3) "foo" } Fatal error: Uncaught Error: Cannot access protected property A::$property in /in/QIVCg:16 Stack trace: #0 {main} thrown in /in/QIVCg on line 16
Process exited with code 255.

preferences:
178.66 ms | 403 KiB | 177 Q