3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Person { private $name; private $age; public function setName($name) { $this->name = $name; } public function setAge($age) { $this->age = $age; } } $person = new Person(); $person->setName("John Doe"); $person->setAge("53"); echo $person->name; echo $person->age;
based on U920I
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Cannot access private property Person::$name in /in/KVNSC:20 Stack trace: #0 {main} thrown in /in/KVNSC on line 20
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Fatal error: Cannot access private property Person::$name in /in/KVNSC on line 20
Process exited with code 255.