Example of using get_object_vars() method in php

怪我咯
Release: 2023-03-13 06:06:02
Original
3215 people have browsed it

This article mainly introduces the usage of get_object_vars() method in PHP. The example analyzes the use of get_object_vars() method to obtain attribute in object. For tips, friends in need can refer to

This article analyzes the usage of the 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

Instance:

<?php
class person{
 public $name="王美人";
 public $age = 25;
 public $birth;
}
$p = new person();
print_r(get_object_vars($p));
?>
Copy after login

Output result:

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

The above is the detailed content of Example of using get_object_vars() method in php. For more information, please follow other related articles on the PHP Chinese website!

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!