Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blade view: if statement with OR/AND condition

Tags:

Is it possible in Laravel 4.0 -blade-view to do an if statment like so?

@if ($var1 === '1' OR $var2 === '1')
    //Do my stuff
@endif

Or

@if ($var1 === '1' || $var2 === '1')
    //Do my stuff
@endif

Or whatever syntax it is. I didn't find anything in the L4 docs, does it exist ?

like image 728
toesslab Avatar asked Dec 30 '13 13:12

toesslab


People also ask

How do you check if a variable is set or not in Laravel?

You can use the @isset blade directive to check whether the variable is set or not.

What is Blade template in Laravel?

The Blade is a powerful templating engine in a Laravel framework. The blade allows to use the templating engine easily, and it makes the syntax writing very simple. The blade templating engine provides its own structure such as conditional statements and loops.


1 Answers

It should support all of your standard PHP operators, including || (logical OR).

I have tested it myself and it works fine.

Additionally, I would recommend simply testing this yourself in future to confirm it works/doesn't work.

like image 92
JaTochNietDan Avatar answered Dec 15 '22 01:12

JaTochNietDan