PHP Laravel Blade {{{name or 'Default'}}} printing 1

0

According to the Laravel documentation

{{{ $name or 'Default' }}}

should behave like

if(isset($name))
   echo $name
else
   echo 'Default'

or

echo isset($title) ? $title : 'Default'

But it is returning 1 as if it were a true .

Now I'm using {{ isset($title) ? $title : 'Default' }} and it's working, but I'd like to understand what happens in the first version, does anyone know why I get 1 ?

    
asked by anonymous 13.09.2018 / 11:44

1 answer

1

Try to use {{ $name or 'Default' }} (with only two keys). Apparently the way your code is, the value returned is the logical value of the expression "$ name or 'Default'", which in this case returns true because PHP interprets a non-empty string as true.

    
13.09.2018 / 14:13