gpt4 book ai didi

php - 检查 Laravel View 中是否为 null 和空字符串

转载 作者:可可西里 更新时间:2023-11-01 13:35:39 25 4
gpt4 key购买 nike

在我看来,我必须分别输出一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com