Modern PHP

From Rixort Wiki
Revision as of 20:37, 10 April 2018 by Paul (talk | contribs)
Jump to navigation Jump to search

Generators

Generators are similar to iterators that calculate their values on demand, thus potentially using fewer resources. They can be created using the yield keyword, e.g.:

function my_generator()
{
  yield 1;
  yield 2;
  yield 3;
}

Useful dependencies

Links