Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

get object vars function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php get object vars () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 4 , PHP 5)

get_object_vars -- Returns an associative array of object properties

Syntax

array get_object_vars ( object obj )

This function returns an associative array of defined object properties for the specified object obj.

Note: In versions prior to PHP 4.2.0, if the variables declared in the class of which the obj is an instance, have not been assigned a value, those will not be returned in the array. In versions after PHP 4.2.0, the key will be assigned with a NULL value.

Example 1. Use of 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));

?>

The above example will output:

Array
 (
     [x] => 1.233
     [y] => 3.445
     [label] =>
 )

 Array
 (
     [x] => 1.233
     [y] => 3.445
     [label] => point #1
 )

See also get_class_methods() and get_class_vars().

Php get object vars Function syntax tag

get object vars php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php get object vars syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online