- var_dump: documentation ( source)
<?php
try {
function hello_1(?string $whom): ?string {
if ($whom !== null) {
return "Hello $whom";
}
}
var_dump(hello_1(null));
} catch (\Error $e) {
echo $e->getMessage() . PHP_EOL;
}
/*try {
function hello_2(?string $whom): ?string {
if ($whom !== null) {
return "Hello $whom";
}
return;
}
var_dump(hello_2(null));
} catch (\Error $e) {
echo $e->getMessage() . PHP_EOL;
}
Fatal error: A function with return type must return a value (did you mean "return null;" instead of "return;"?) in /in/QRj2G on line 20
*/
try {
function hello_3(?string $whom): ?string {
if ($whom !== null) {
return "Hello $whom";
}
return null;
}
var_dump(hello_3(null));
} catch (\Error $e) {
echo $e->getMessage() . PHP_EOL;
}