Usage examples of get_object_vars() method in php_PHP tutorial

WBOY
Release: 2016-07-13 10:07:33
Original
1067 people have browsed it

Usage examples of get_object_vars() method in php

This article mainly introduces the usage of get_object_vars() method in php, and analyzes the use of get_object_vars() method to obtain attributes in objects with examples. Tips, friends in need can refer to it

This article analyzes the usage of get_object_vars() method in PHP with examples. Share it with everyone for your reference. The specific analysis is as follows:

Syntax: get_object_var($object), returns an array. Get the attributes in the $object object and form an array

Example:

?

1

2

3

4

5

6

7

8

9

class person{

public $name="王美人";

public $age = 25;

public $birth;

}

$p = new person();

print_r(get_object_vars($p));

?>

1 2

3

4

5

6

1

Array ( [name] => 王美人 [age] => 25 [birth] => )

7 8

9
class person{public $name="王美人"; public $age = 25; public $birth; } $p = new person(); print_r(get_object_vars($p));

?>
Output result: ?
1 Array ( [name] => 王美人 [age] => 25 [birth] => )
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/955274.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/955274.htmlTechArticleUsage examples of get_object_vars() method in php. This article mainly introduces the usage of get_object_vars() method in php and example analysis. To learn how to use the get_object_vars() method to obtain the attributes in an object, you need to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!