3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php interface ConfiguratorDelegate { public function didSelectOption($option); } class ViewController implements ConfiguratorDelegate { public function didSelectOption($option) { echo "Selected option"; } public function __construct() { $configurator = new Configurator(); $configurator->delegate = $this; // This is not how it works, this just shows the chain $configurator->optionSelected('derp'); } } class Configurator { public $delegate; // This would be defined as an object that always implements ConfiguratorDelegate private function optionSelected($option) { if ($delegate) { $delegate->didSelectOption($option); } } } $myVC = new ViewController();
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to private method Configurator::optionSelected() from context 'ViewController' in /in/n3lJT:19 Stack trace: #0 /in/n3lJT(34): ViewController->__construct() #1 {main} thrown in /in/n3lJT on line 19
Process exited with code 255.
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Fatal error: Call to private method Configurator::optionSelected() from context 'ViewController' in /in/n3lJT on line 19
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/n3lJT on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/n3lJT on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/n3lJT on line 3
Process exited with code 255.