3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Item { private $timeout = 0; public function expiresAfter($timeout) { $this->timeout = $timeout; } public function getTimeout() { return $this->timeout; } } class CacheHelper { static public function expiresAfter($time) { return function ($item) use ($time) { $item->expiresAfter($time); }; } } $item = new Item; (CacheHelper::expiresAfter(30))($item); echo $item->getTimeout();
based on FKZvN
Output for 7.0.0 - 7.2.0
30
Output for 5.3.18 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/Eofqs on line 29
Process exited with code 255.