gpt4 book ai didi

Laravel 检查属性存在

转载 作者:行者123 更新时间:2023-12-04 21:46:36 25 4
gpt4 key购买 nike

我如何检查现有属性(property) $this->team->playerAssignment->player以更理性的方式?现在我像这样检查它:

if ($this->team)
if (($this->team->playerAssignment))
if (($this->team->playerAssignment->player))

最佳答案

试试isset php函数。

isset — 确定变量是否已设置且不为 NULL

if(isset($this->team->playerAssignment->player)){

}

关于Laravel 检查属性存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46301623/

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