php三目运算如何简写,我今天才知道
2022-07-28 15:09:43
150
{{single.collect_count}}

php三目运算如何简写,我今天才知道

今天在学习laralvel框架的时候,发现了这么一行代码

1 $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');

 

然后单纯的我试了试

$token = 1 ?: 0;dd($token);//return 1

 

竟然可以这样!我今天才知道!看来有必要把手册再看一遍

 

 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}