Bug #67631 [Opn->Csd]: Yield command doens't work

From: Date: Wed, 16 Jul 2014 12:56:52 +0000
Subject: Bug #67631 [Opn->Csd]: Yield command doens't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186664@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67631&edit=1 ID: 67631 User updated by: lferro9000 at gmail dot com Reported by: lferro9000 at gmail dot com Summary: Yield command doens't work -Status: Open +Status: Closed Type: Bug Package: *General Issues Operating System: MacOSx PHP Version: 5.5.14 Block user comment: N Private report: N New Comment: Issue with multiple versions of PHP on the computer. Previous Comments: ------------------------------------------------------------------------ [2014-07-16 12:38:52] lferro9000 at gmail dot com Line 5 i mean (the line with the yield statement). ------------------------------------------------------------------------ [2014-07-16 12:37:43] lferro9000 at gmail dot com Description: ------------ --- From manual page: http://www.php.net/language.generators.syntax --- The Yield command which has the syntax: yield $var; In it's basic form doesn't work and issues on CLI the following error: Parse error: parse error in test.php on line 7 Test script: --------------- Test script is the example posted on the generators page: <?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 "$value\n"; } Expected result: ---------------- The yield command should work as documented. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67631&edit=1

« previous php.bugs (#186664) next »