Blade view: if statement with OR/AND condition

前端 未结 2 903
轮回少年
轮回少年 2021-02-07 08:02

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


        
相关标签:
2条回答
  • 2021-02-07 08:25

    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.

    0 讨论(0)
  • 2021-02-07 08:38

    You can simply use and / or operators:

    @if($a==1 and $b==2)
    @if($a==1 or $b==2)
    
    0 讨论(0)
提交回复
热议问题