PHP get_object_vars
来源:互联网 发布:java 自动化发布 编辑:程序博客网 时间:2024/05/21 07:07
(PHP 4, PHP 5, PHP 7)
get_object_vars — 返回由对象属性组成的关联数组
说明
array get_object_vars ( object
$obj
)返回由 obj
指定的对象中定义的属性组成的关联数组。
Note:
在 PHP 4.2.0 之前的版本中,如果在
obj
对象实例中声明的变量没有被赋值,则它们将不会在返回的数组中。而在 PHP 4.2.0 之后,这些变量作为键名将被赋予NULL
值。
Example #1 使用 get_object_vars()
<?php
class Point2D {
var $x, $y;
var $label;
function Point2D($x, $y)
{
$this->x = $x;
$this->y = $y;
}
function setLabel($label)
{
$this->label = $label;
}
function getPoint()
{
return array("x" => $this->x,
"y" => $this->y,
"label" => $this->label);
}
}
// "$label" is declared but not defined
$p1 = new Point2D(1.233, 3.445);
print_r(get_object_vars($p1));
$p1->setLabel("point #1");
print_r(get_object_vars($p1));
?>
以上例程会输出:
Array ( [x] => 1.233 [y] => 3.445 [label] => ) Array ( [x] => 1.233 [y] => 3.445 [label] => point #1 )
0 0
- PHP get_object_vars
- get_object_vars()用法(PHP)
- php get_object_vars()函数
- get_object_vars
- get_object_vars()
- [php] get_object_vars() 返回类中所有的非静态属性
- array get_object_vars
- get_class_vars 和 get_object_vars区别
- get_object_vars 返回由对象属性组成的关联数组
- PHP
- PHP
- php
- php
- PHP
- PHP
- php
- php
- php
- 基本算法题练习一
- unittest 生成 HTMLTestRunner 测试报告
- VMware压缩linux虚拟机
- Bootstrap中的color,bgcolor,background-clor,border-color
- C#使用(打开浏览器、设置快捷键等)
- PHP get_object_vars
- 解决Hibernate:could not initialize proxy - no Session
- 构造回文串
- 模仿360桌面图标
- Javascript中的href
- mybatis 执行insert语句总是报错,ORA-00911 无效字符错误解决方法
- Android Context导致的内存泄漏分析(示例代码+分析工具使用)
- git命令大全
- array与xml转换实现