Saturday, August 3, 2019

php - Whit what is yeild different from echo

What is the difference between them and this two examples:



function result($r){
for($i=0; $i<$r; $i++){
yield $i;
}
}

foreach(result(15) as $r){

echo $r;
};


And one with echo only:



function result($r){
for($i=0; $i<$r; $i++){
echo $i;
}

}

result(15);


I am sure there is some but what is it? Couldn't answer myself after some googling, sorry.

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...