3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ConfiguratorDelegate { public function didSelectOption($option); } class ViewController implements ConfiguratorDelegate { public function didSelectOption($option) { echo "Selected option"; } __construct() { $configurator = new Configurator(); $configurator->delegate = $this; } } 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 5.4.0 - 5.4.15
Parse error: syntax error, unexpected '__construct' (T_STRING), expecting function (T_FUNCTION) in /in/cZQk5 on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.25
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /in/cZQk5 on line 14
Process exited with code 255.

preferences:
176.03 ms | 1395 KiB | 49 Q