2 /* Prototype: void debug_zval_dump ( mixed $variable );
3 Description: Dumps a string representation of an internal zend value to output.
6 /* Prototype: void zval_dump( $value );
7 Description: use debug_zval_dump() to display the objects and its
9 function zval_dump( $values ) {
11 foreach( $values as $value ) {
12 echo "-- Iteration $counter --\n";
13 debug_zval_dump( $value );
18 /* checking on objects type */
19 echo "*** Testing debug_zval_dump() on objects ***\n";
23 protected $value3 = 20;
26 private function foo1() {
27 echo "function foo1\n";
29 protected function foo2() {
30 echo "function foo2\n";
32 public function foo3() {
33 echo "function foo3\n";
35 public $array_var = array( "key1" => 1, "key2 " => 3);
37 function object_class () {
39 $this->object_class1
= $this;
43 class no_member_class
{
47 /* class with member as object of other class */
48 class contains_object_class
54 public $class_object2;
55 private $class_object3;
56 protected $class_object4;
57 var $no_member_class_object;
59 public function func() {
60 echo "func() is called \n";
63 function contains_object_class () {
64 $this->class_object1
= new object_class();
65 $this->class_object2
= new object_class();
66 $this->class_object3
= $this->class_object1
;
67 $this->class_object4
= $this->class_object2
;
68 $this->no_member_class_object
= new no_member_class();
69 $this->class_object5
= $this; //recursive reference
73 /* creating new object $obj */
74 $obj = new contains_object_class();
75 $obj1 = & $obj; //object $obj1 references object $obj
79 /* object which is unset */
80 $unset_obj = new object_class();
89 $obj->no_member_class_object
,
90 @$temp_class_obj, //undefined object
93 $obj2->class_object1
->value4
,
96 /* using zval_dump() to dump out the objects and its reference count */
100 $obj = $int_var; //$obj is lost, $obj1,$obj2,$obj3,$obj4 = 500
101 echo "\n-- Testing debug_zval_dump() on overwritten object variables --\n";
102 debug_zval_dump($obj, $obj1, $obj2, $obj3);
104 echo "\n-- Testing debug_zval_dump() on objects having circular reference --\n";
105 $recursion_obj1 = new object_class();
106 $recursion_obj2 = new object_class();
107 $recursion_obj1->obj
= &$recursion_obj2; //circular reference
108 $recursion_obj2->obj
= &$recursion_obj1; //circular reference
109 debug_zval_dump($recursion_obj2);