Generator::sendSend a value to the generator Description
public mixed Generator::send
( mixed
$value
)Sends the given value to the generator as the result of the yield expression and resumes execution of the generator. Generator::send allows values to be injected into generator functions while iterating over them. The injected value will be returned from the yield statement and can then be used like any other variable within the generator function. Parameters
Examples
Example #1 Using Generator::send to inject values
<?php The above example will output: Hello world! Return ValuesReturns the yielded value. |