简体   繁体   中英

Blade view: if statement with OR/AND condition

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 ?

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.

You can simply use and / or operators:

@if($a==1 and $b==2)
@if($a==1 or $b==2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM