-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
The foreach should also throw a fatal error "PHP Fatal error: Uncaught Error: Cannot use object of type Closure as array"
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
$test = [
'a' => 1,
'b' => function() {
echo 'called' . PHP_EOL;
return [1, 2, 3];
}
];
echo '1' . PHP_EOL;
print_r($test);
foreach($test['b'] as $item) { // no error reported
print_r($item);
}
print_r($test['b'][0]); // error reported
echo '2' . PHP_EOL;