3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private $a; public function getA() { return $this->a; } public function setA($a) { $this->a = $a; } } $a = new A(); $a->setA("coucou"); echo $a->getA(); modifyA($a); echo $a->getA(); $b = 'b'; testA(null); testA($b); function modifyA(A $a) { $a->setA('B'); } function testA(A $a = null) { }
based on jl6eE
Output for 7.1.0 - 7.2.0
coucouB Fatal error: Uncaught TypeError: Argument 1 passed to testA() must be an instance of A or null, string given, called in /in/unmb3 on line 27 and defined in /in/unmb3:35 Stack trace: #0 /in/unmb3(27): testA('b') #1 {main} thrown in /in/unmb3 on line 35
Process exited with code 255.
Output for 7.0.0 - 7.0.20
coucouB Fatal error: Uncaught TypeError: Argument 1 passed to testA() must be an instance of A, string given, called in /in/unmb3 on line 27 and defined in /in/unmb3:35 Stack trace: #0 /in/unmb3(27): testA('b') #1 {main} thrown in /in/unmb3 on line 35
Process exited with code 255.
Output for 5.3.18 - 5.6.28
coucouB Catchable fatal error: Argument 1 passed to testA() must be an instance of A, string given, called in /in/unmb3 on line 27 and defined in /in/unmb3 on line 35
Process exited with code 255.