Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
get_object_vars() function in PHP
The get_object_var() function gets the properties of the given object. It returns an associative array of defined object properties for the specified object.
Syntax
get_object_vars(object)
Parameters
object − An object instance.
Return
The get_object_var() function returns an associative array of defined object properties for the specified object. If a property have not been assigned a value, it will be returned with a NULL value.
Example
The following is an example −
<?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);
}
}
$p1 = new Point2D(9.675, 8.321);
print_r(get_object_vars($p1));
$p1->setLabel("point #1");
print_r(get_object_vars($p1));
?>
Output
The following is the output −
Array ( [x] => 9.675 [y] => 8.321 [label] => ) Array ( [x] => 9.675 [y] => 8.321 [label] => point #1 )
Advertisements