Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Generator

generator has several distinct usages:

  • Yield generator: a function or method that uses yield, implicitly returning an instance of \Generator and implementing the Iterator interface without the boilerplate of writing one
  • Random number generator: an algorithm or function, such as rand(), mt_rand(), or the Random\Engine classes, that produces a sequence of numbers that appears random
  • Code generator: a tool or library that automates the creation of boilerplate PHP code from templates, configuration, or a schema

Absent further context, generator most often refers to the yield generator.

Documentation