Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Comment Inside yield from

It was possible to insert a comment between the yield and the from.

In PHP 8.3 more recent, this would not compile, unless there was a defined constant called from.

PHP code

<?php
 
function foo() {
    yield /*a*/  from [3];
} 

foreach(foo() as $i) {
    print $i;
}
?>

Before

PHP Fatal error:  Uncaught Error: Undefined constant "from" 

Fatal error: Uncaught Error: Undefined constant "from" 

After

3

PHP version change

This behavior changed in 8.3.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat