Answers for "?? ' ' operator in php laravel"

PHP
1

?? ' ' operator in php laravel

// Null Coalesce Operator in PHP (Laravel) - $statement ?? ''
$categoryName = $category->name ?? 'Not Available';

// The above Statement is identical to this if/else statement
if (isset($category->name)) {
    $categoryName = $category->name;
} else {
    $categoryName  = 'Not Available';
}
Posted by: Guest on February-16-2021

Browse Popular Code Answers by Language