3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { protected $_dependency = ''; public function __construct(string $dependency = '') { if (! empty($dependency)) { $this->_dependency = $dependency; } } public function getDependency() { return $this->_dependency; } } class Bar extends Foo { } $a = new Bar('some dependency'); var_dump($a->getDependency());
based on itELE
Output for 7.0.0 - 7.2.0
string(15) "some dependency"
Output for 5.4.0 - 5.6.28
Fatal error: Default value for parameters with a class type hint can only be NULL in /in/JmVFP on line 5
Process exited with code 255.