3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace A { class T {} } namespace { class Test { public function first(string $str) : Closure { return function() use (string $str) : int { return strlen($str); }; } public function second(): self { return $self; } } $t = new Test; echo ($t->second()->first("hello"))(); }
Output for 7.0.0
Parse error: syntax error, unexpected 'string' (T_STRING), expecting '&' or variable (T_VARIABLE) in /in/VnT3T on line 12
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/VnT3T on line 10
Process exited with code 255.

preferences:
165.08 ms | 1395 KiB | 24 Q