I wrote this code
<p>{{ $name or 'hello' }}</p>,
but it return just 1. I read, that it's syntax used in Laravel 5.7, not higher and change my code to this
<p>{{ $name ?? 'hello' }}</p>.
But this code return nothing. Help me, please.
CodePudding user response:
Use ternary operator instead
<p>{{ $name ?: 'hello' }}</p>
?? is null coalescing operator and in your case $name is not null but empty string.
