3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function getFunc($text) { return function() use ($text) { $withNewLine = $text.PHP_EOL; printf("From the inside: %s", $withNewLine); return $withNewLine; }; } } $b = new A(); $func = $b->getFunc('can i has var'); $func(); $c = ($b->getFunc('can i has var'))(); echo 'From the outside:'.PHP_EOL; echo $c;

preferences:
51.16 ms | 402 KiB | 5 Q