2
I know that in the javascript
the use of self invoking functions
, especially when it comes to variable scope protection.
I was doing tests on PHP 7
and I see that we have the same possibility to use the Self Invoking Function
- functions that can be called at the same time that are declared.
Example:
$gen = (function() {
yield 1;
yield 2;
return 3;
})()
foreach ($gen as $number) {
echo $number;
}
The exit is:
1
2
3
In this case the use of Generator
, I see a lot of use.
What other possible advantages are the use of Self Invoking Function
in PHP7
?
Look, that example was fine, huh.
– Wallace Maxters
I improved it. Now yes it is suitable.
– Leonel Sanches da Silva
For those who don’t like PHP, until you know a lot, huh.
– Wallace Maxters
I was a PHP programmer. I think I told you before.
– Leonel Sanches da Silva
I think there’s going to be a "Mortar" like this
– Wallace Maxters