<?php
// Mapeia a função de callback para elementos de um array.
print_r(array_map(function($name) {
return "Olá, " . ucfirst($name) . "!";
}, $names));
Warning: Undefined variable $names in /in/5sRk9 on line 6
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /in/5sRk9:4
Stack trace:
#0 /in/5sRk9(4): array_map(Object(Closure), NULL)
#1 {main}
thrown in /in/5sRk9 on line 4
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: Undefined variable $names in /in/5sRk9 on line 6
Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /in/5sRk9:6
Stack trace:
#0 /in/5sRk9(6): array_map(Object(Closure), NULL)
#1 {main}
thrown in /in/5sRk9 on line 6
Process exited with code 255.