3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Person { private $_name = 'sina'; private $_age = '27'; private $_employer = 'yes'; public function get_name() { return $this->_name; } public function get_age() { return $this->_age; } public function get_employer() { return $this->_employer; } } $person = new Person(); $person->get_name(); $required = array('name','age'); foreach($required as $req) { $func = "get_{$req}()"; echo $person->$$func; }
based on YDckD
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: get_name() in /in/JWjH2 on line 32 Notice: Undefined property: Person::$ in /in/JWjH2 on line 32 Notice: Undefined variable: get_age() in /in/JWjH2 on line 32 Notice: Undefined property: Person::$ in /in/JWjH2 on line 32
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: get_name() in /in/JWjH2 on line 32 Fatal error: Uncaught Error: Cannot access empty property in /in/JWjH2:32 Stack trace: #0 {main} thrown in /in/JWjH2 on line 32
Process exited with code 255.
Output for 5.3.21 - 5.6.28
Notice: Undefined variable: get_name() in /in/JWjH2 on line 32 Fatal error: Cannot access empty property in /in/JWjH2 on line 32
Process exited with code 255.