Generator::throwThrow an exception into the generator Beschreibung
public mixed Generator::throw
( Throwable
$exception
)Throws an exception into the generator and resumes execution of the generator. The behavior will be the same as if the current yield expression was replaced with a throw $exception statement. If the generator is already closed when this method is invoked, the exception will be thrown in the caller's context instead. Parameter-Liste
RückgabewerteReturns the yielded value. Changelog
Beispiele
Beispiel #1 Throwing an exception into a generator
<?phpDas oben gezeigte Beispiel erzeugt folgende Ausgabe: Foo Exception: Test Bar |