[ create a new paste ] login | about

Link: http://codepad.org/pIqBv4Vi    [ raw code | output | fork ]

PHP, pasted on Oct 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php

function get_object_public_vars($object) {
    return get_object_vars($object);
}

class Foo {
   public $public = 'public';
   private $private = 'private';
   public function getVars() {
      $refl = new ReflectionObject($this);
      return $refl->getProperties(ReflectionProperty::IS_PUBLIC);
   }
}

$object = new Foo;
print_r($object->getVars());


Output:
1
2
3
4
5
6
7
8
9
Array
(
    [0] => ReflectionProperty Object
        (
            [name] => public
            [class] => Foo
        )

)


Create a new paste based on this one


Comments: