PHP 8.5.0 Alpha 4 available for testing

Voting

: seven minus one?
(Example: nine)

The Note You're Voting On

zilvinas at kuusas dot lt
9 years ago
Do not call generator functions directly, that won't work.

<?php

function my_transform($value) {
var_dump($value);
return
$value * 2;
}

function
my_function(array $values) {
foreach (
$values as $value) {
yield
my_transform($value);
}
}

$data = [1, 5, 10];
// my_transform() won't be called inside my_function()
my_function($data);

# my_transform() will be called.
foreach (my_function($data) as $val) {
// ...
}
?>

<< Back to user notes page

To Top