PHP yield Keyword

PHP Keywords : Use yield to create a generator function

Definition and Usage

The yield keyword is used to create a generator function. Generator functions act as iterators which can be looped through with a foreach loop.

The value given by the yield keyword is used as a value in one of the iterations of the loop.

Related Pages

The foreach keyword.

The yield from keyword.

❮ PHP Keywords