3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Father { private $son; private $foo = ''; function getFoo() { return $this->foo; } } class Son { private $father; public function __construct(Father $dad) { $this->father = $dad; } function setFoo($value) { $this->dad->setFoo($value); } } $father = new Father(); $son = new Son($father); $son->setFoo('bar'); echo $father->getFoo(); //I want it to now be 'bar'
Output for 7.0.30 - 7.3.0beta1
Notice: Undefined property: Son::$dad in /in/e4DcD on line 26 Fatal error: Uncaught Error: Call to a member function setFoo() on null in /in/e4DcD:26 Stack trace: #0 /in/e4DcD(33): Son->setFoo('bar') #1 {main} thrown in /in/e4DcD on line 26
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Undefined property: Son::$dad in /in/e4DcD on line -1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function setFoo() on a non-object (null)' in /in/e4DcD:-1 Stack trace: #0 /in/e4DcD(-1): Son->setFoo() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Notice: Undefined property: Son::$dad in /in/e4DcD on line 26 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function setFoo() on a non-object (null)' in /in/e4DcD:26 Stack trace: #0 /in/e4DcD(33): Son->setFoo() #1 {main}
Process exited with code 255.
Output for 5.6.30
Notice: Undefined property: Son::$dad in /in/e4DcD on line 26 Fatal error: Call to a member function setFoo() on null in /in/e4DcD on line 26
Process exited with code 255.