- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这一行:
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() 不起作用?
最佳答案
关于php - get_object_vars 返回 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7428099/
这是我的用户类: load($id); } /** * @TODO PhpDoc */ public static function factory($id
函数应该返回数组 public static function categories() { // return array of categories $categories = C
get_object_vars($obj) 和 (array) $obj 有区别吗? 两者似乎都返回对象的公共(public)属性。 哪个更好? 最佳答案 这并不完全正确。 get_object_va
关于PHP,有什么区别: get_class_vars() get_object_vars() 最佳答案 get_class_vars() 获取 class_nameget_object_vars()
这一行: var_dump($data['department']); 返回这个: object(Penny\HomeBundle\Entity\Department)[1420] protect
我有一些相互扩展的类,每次都添加更多属性。 现在我需要获取一个类的所有属性的列表,但是按照它们被声明的顺序,首先是父类的属性。 例如: class foo { public $a = 1;
功能实现有时会因版本而异,但这并不奇怪,但不是这样......看: $array = ["abc","def"]; $object = new stdclass(); foreach($array a
我已经使用 get_object_vars 一段时间了。它总是只返回一个对象的公共(public)属性,但突然间它也返回 protected 变量?!?怎么可能?它以前从未这样做过 代码 print_
在这个例子中,我假设从 data 调用的函数 getVars 将能够返回 B 的私有(private)变量名称,因为 $this 是 B 的实例。 取而代之的是,$this->getVars() 返回
在这个例子中,我假设从 data 调用的函数 getVars 将能够返回 B 的私有(private)变量名称,因为 $this 是 B 的实例。 取而代之的是,$this->getVars() 返回
我得到了这个结果array(1) { ["meta_value"]=> string(1) "5"} 在选择语句请求之后 $mp = $wpdb->get_row( $wpdb->prepare( "
我需要获取对象的公共(public)属性;有这样做的首选方法吗?由于反射 API 的开销,我对使用 ReflectionObject#getProperties() 持谨慎态度,但是在将对象转换为数组
我是一名优秀的程序员,十分优秀!