Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the new features of the generator in PHP7

Shulou Source: shulou.com Published: 2022-06-03 18:41:39 10月04日 Update

This article mainly introduces what are the new features of the generator in PHP7. It is very detailed and has a certain reference value. Friends who are interested must read it!

A New feature of Generator in PHP7 yield-from & & return-values

Generator delegation

Simply translate the description of the official document:

In PHP7, other generators, iteratable objects, and arrays can be delegated to the outer generator through the generator yield from. The outer generator first orders the values delegated by yield, and then continues the values defined in the yield itself.

Using yield from makes it easier for us to write nesting generators that are relatively clear, and code nesting calls are necessary for writing complex systems.

The above example is:

Tags: Generator generation feature code example delegate middle student server service output iteration content outer layer method article blocking complexity admiral two value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple MariaDB Shulou Technology MySQL NVidia