Generator::current

(PHP 5 >= 5.5.0)

Generator::currentGet the yielded value

Описание

public mixed Generator::current ( void )

Список параметров

У этой функции нет параметров.

Возвращаемые значения

Returns the yielded value.

Коментарии

<?php
function gen_one_to_three() {
    for (
$i 1$i <= 3$i++) {
       
// Note that $i is preserved between yields.
       
yield $i;
    }
}

$generator gen_one_to_three();
foreach (
$generator as $value) {
    echo 
"regular : ".$value PHP_EOL;
    echo 
"With current function : ".$generator->current(),PHP_EOL;
}
?>
2018-01-31 00:48:59
http://php5.kiev.ua/manual/ru/generator.current.html
Автор:
current() advances untouched generator, same as next(), it makes the first step/iteration. the following calls will not.

non-yielded value will be NULL
2021-11-12 04:41:57
http://php5.kiev.ua/manual/ru/generator.current.html

    Поддержать сайт на родительском проекте КГБ