Laravel Blade中的三元 [英] Ternary in Laravel Blade

查看:680
本文介绍了Laravel Blade中的三元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找刀片模板的三元运算符

Looking for a ternary operator for blade templates

@if(Auth::check()) ? yes : no @endif

似乎无法使其正常工作

@if(Auth::check()) yes @else no @endif

假设此示例中没有太多内容,只是出于好奇.

suppose there is not much in it for this example, just curious.

推荐答案

您可以自由地将其与{{ }}一起使用.

You are free to use it with {{ }}.

{{ Auth::check() ? 'yes' : 'no' }}

这篇关于Laravel Blade中的三元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆