PHP 8.5.0 Alpha 4 available for testing

Voting

: max(six, nine)?
(Example: nine)

The Note You're Voting On

sergei dot solomonov at gmail dot com
11 years ago
<?php
function foo() {
$string = yield;
echo
$string;
for (
$i = 1; $i <= 3; $i++) {
yield
$i;
}
}

$generator = foo();
$generator->send('Hello world!');
foreach (
$generator as $value) echo "$value\n";
?>

This code falls with the error:
PHP Fatal error: Uncaught exception 'Exception' with message 'Cannot rewind a generator that was already run'.
foreach internally calls rewind, you should remember this!

<< Back to user notes page

To Top