3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyCl { protected $db = "Hello"; public function __get($property) { return $this->db; } } $obj = new MyCl(); $greet = $obj->db; var_dump($greet); $obj->db = "World";
based on L8tYC
Output for 7.0.28 - 7.3.0rc3
string(5) "Hello" Fatal error: Uncaught Error: Cannot access protected property MyCl::$db in /in/S2OYW:15 Stack trace: #0 {main} thrown in /in/S2OYW on line 15
Process exited with code 255.
Output for 5.6.38
string(5) "Hello" Fatal error: Cannot access protected property MyCl::$db in /in/S2OYW on line 15
Process exited with code 255.