How do you write a PHP arrow function with multiple line expressions?
JavaScript one-liner example:
const dob = (age) => 2021 - age;
PHP one-liner equivalent:
$dob = fn($age) => 2021 - $age;
Javascript multiple line example:
const dob = (age) => {
if (!age) {
return null;
}
const new_age = 2021 - age;
console.log("Your new age is " + new_age);
return new_age;
}
What is the PHP equivalent for multiple lines within an arrow function?