在我看来,我必须分别输出一个 null
和一个 empty string
所以我有这个:
@if( $str->a == null)
... // do somethin
@endif
@if( $str->a == '')
... // do somethin
@endif
问题是它们的结果相同。
谢谢
最佳答案
在评论中您说过您只想检查它是否为 null
。所以,使用 is_null()
:
@if (is_null($str->a))
// do somethin
@endif
关于php - 检查 Laravel View 中是否为 null 和空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45243205/