import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-general_functions / debug_zval_dump_o.php
blobc8dd7088d3d343757fdb17101a77d5c1b99e3315
1 <?php
2 /* Prototype: void debug_zval_dump ( mixed $variable );
3 Description: Dumps a string representation of an internal zend value to output.
4 */
6 /* Prototype: void zval_dump( $value );
7 Description: use debug_zval_dump() to display the objects and its
8 reference count */
9 function zval_dump( $values ) {
10 $counter = 1;
11 foreach( $values as $value ) {
12 echo "-- Iteration $counter --\n";
13 debug_zval_dump( $value );
14 $counter++;
18 /* checking on objects type */
19 echo "*** Testing debug_zval_dump() on objects ***\n";
20 class object_class {
21 var $value1 = 1;
22 private $value2 = 10;
23 protected $value3 = 20;
24 public $value4 = 30;
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 () {
38 $this->value1 = 5;
39 $this->object_class1 = $this;
43 class no_member_class{
44 //no members
47 /* class with member as object of other class */
48 class contains_object_class
50 var $p = 30;
51 protected $p1 = 40;
52 private $p2 = 50;
53 var $class_object1;
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
76 $obj2 = & $obj;
77 $obj3 = & $obj2;
79 /* object which is unset */
80 $unset_obj = new object_class();
81 unset($unset_obj);
83 $objects = array (
84 new object_class,
85 new no_member_class,
86 $obj,
87 $obj->class_object1,
88 $obj->class_object2,
89 $obj->no_member_class_object,
90 @$temp_class_obj, //undefined object
91 $obj2->class_object1,
92 $obj3->class_object2,
93 $obj2->class_object1->value4,
94 @$unset_obj
96 /* using zval_dump() to dump out the objects and its reference count */
97 zval_dump($objects);
99 $int_var = 500;
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);
111 echo "Done\n";