In JavaScript, you can define anonymous functions that are executed immediately:
(function () { /* do something */ })()
Can you do somethin
In PHP 7 is to do the same in javascript
PHP 7
$gen = (function() { yield 1; yield 2; return 3; })(); foreach ($gen as $val) { echo $val, PHP_EOL; } echo $gen->getReturn(), PHP_EOL;
The output is:
1 2 3