Operator "or" of Blade Laravel does not work

Asked

Viewed 269 times

0

When I try to use the operator "or" in the Blade it processes wrong and the Undefined variable. I’m calling it that:

  {{ $confirmed or false }}

But he’s compiling it like this:

  <?php echo e($confirmed or false); ?>
  • what is your intention? whether the $Confirmed variable exists? whether it is true? explains better

  • if true, if not, I automatically want to receive false

2 answers

1

The basic correct use is:

{{ $confirmed or 'false' }}

In case you’re trying to put the false as an element, not a string or variável.

  • I put @if ($Confirmed or 'false') and still gave Undefined variable

1

Try it like this:

{{ isset($confirmed) ? 'valor se ok' : 'valor se nao existe'; }}

or use the form below to return the value of the variable itself:

{{ isset($confirmed) ? $confirmed : 'valor se nao existe'; }}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.