3v4l.org

run code in 300+ PHP versions simultaneously
<?php class example { public $foo; public function__construct() { $this->function = foo() { return 24; }; } } $exp = new example(); echo ($exp->function)(), PHP_EOL;
Output for 7.1.0 - 7.1.23, 7.2.0 - 7.2.11
Parse error: syntax error, unexpected 'function__construct' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/io8rI on line 7
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected 'function__construct' (T_STRING), expecting variable (T_VARIABLE) in /in/io8rI on line 7
Process exited with code 255.

preferences:
188.15 ms | 1395 KiB | 44 Q