3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bear { private $age = 0; public function setAge($age) { if ($age < 0) { throw new Exception('Bear cannot have negative age dumbass'); } $this->age = $age; } public function getAge() { return $this->age; } } class BlackBear { private $name; public function setNameAndAge($name, $age) { $this->name = $name; $this->setAge($age); } } $bear1 = new Bear(); $bear1->setAge(35); $bear2 = new BlackBear(); $bear2->setNameAndAge('Harry', 45); var_dump($bear1->getAge()); var_dump($bear2->getAge());
based on BntCX
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to undefined method BlackBear::setAge() in /in/0CK9i:28 Stack trace: #0 /in/0CK9i(37): BlackBear->setNameAndAge('Harry', 45) #1 {main} thrown in /in/0CK9i on line 28
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: Call to undefined method BlackBear::setAge() in /in/0CK9i on line 28
Process exited with code 255.