Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

?? 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';
}
 
PREVIOUS NEXT
Tagged: #operator #php #laravel
ADD COMMENT
Topic
Name
6+7 =