gpt4 book ai didi

php - get_object_vars 返回 NULL

转载 作者:可可西里 更新时间:2023-11-01 01:07:33 30 4
gpt4 key购买 nike

这一行:

var_dump($data['department']);

返回这个:

object(Penny\HomeBundle\Entity\Department)[1420]
protected 'id' => int 37
protected 'name' => string 'Support' (length=7)
protected 'email' => string 'denis_nizetic@hotmail.com' (length=25)

当我尝试做的时候

var_dump(get_object_vars($data['department']));

我明白了

array
empty

如果对象在那里,我不知道为什么会发生这种情况。

编辑:我使用 $obj->getValue() 方法( setter/getter )解决了我的问题。

但问题仍然存在:为什么 get_object_vars() 不起作用?

最佳答案

来自手册:

Gets the accessible non-static properties

当您的受到保护时。

尝试 get_class_vars .

关于php - get_object_vars 返回 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7428099/

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