1--TEST--
2Test print_r() function
3--INI--
4precision=14
5--FILE--
6<?php
7/* Prototype: bool print_r ( mixed $expression [, bool $return] );
8   Description: Prints human-readable information about a variable
9*/
10
11/* Prototype: void check_printr( $variables )
12   Description: use print_r() to print variables */
13function check_printr( $variables ) {
14  $counter = 1;
15  foreach( $variables as $variable ) {
16    echo "\n-- Iteration $counter --\n";
17    //default = false, prints output to screen
18    print_r($variable);
19    //$return=TRUE, print_r() will return its output, instead of printing it
20    $ret_string = print_r($variable, true); //$ret_string captures the output
21    echo "\n$ret_string\n";
22    //$return=false, print_r() prints the output; default behavior
23    print_r($variable, false);
24    $counter++;
25  }
26}
27
28echo "\n*** Testing print_r() on integer variables ***\n";
29$integers = array (
30  0,  // zero as argument
31  000000123,  //octal value of 83
32  123000000,
33  -00000123,  //octal value of 83
34  -12300000,
35  range(1,10),  // positive values
36  range(-1,-10),  // negative values
37  +2147483647,  // max positive integer
38  +2147483648,  // max positive integer + 1
39  -2147483648,  // min range of integer
40  -2147483647,  // min range of integer + 1
41  0x7FFFFFFF,  // max positive hexadecimal integer
42  -0x80000000,  // min range of hexadecimal integer
43  017777777777,  // max posotive octal integer
44  -020000000000  // min range of octal integer
45);
46/* calling check_printr() to display contents of integer variables
47   using print_r() */
48check_printr($integers);
49
50echo "\n*** Testing print_r() on float variables ***\n";
51$floats = array (
52  -0.0,
53  +0.0,
54  1.234,
55  -1.234,
56  -2.000000,
57  000002.00,
58  -.5,
59  .567,
60  -.6700000e-3,
61  -.6700000E+3,
62  .6700000E+3,
63  .6700000e+3,
64  -4.10003e-3,
65  -4.10003E+3,
66  4.100003e-3,
67  4.100003E+3,
68  1e5,
69  -1e5,
70  1e-5,
71  -1e-5,
72  1e+5,
73  -1e+5,
74  1E5,
75  -1E5,
76  1E+5,
77  -1E+5,
78  1E-5,
79  -1E-5,
80  -0x80000001,  // float value, beyond max negative int
81  0x80000001,  // float value, beyond max positive int
82  020000000001,  // float value, beyond max positive int
83  -020000000001  // float value, beyond max negative int
84);
85/* calling check_printr() to display contents of float variables
86   using print_r() */
87check_printr($floats);
88
89echo "\n*** Testing print_r() on string variables ***\n";
90$strings = array (
91  "",
92  '',
93  " ",
94  ' ',
95  "0",
96  "\0",
97  '\0',
98  "\t",
99  '\t',
100  "PHP",
101  'PHP',
102  "abcd\x0n1234\x0005678\x0000efgh\xijkl",  // strings with hexadecimal NULL
103  "abcd\0efgh\0ijkl\x00mnop\x000qrst\00uvwx\0000yz",  // strings with octal NULL
104  "1234\t\n5678\n\t9100\rabcda"  // strings with escape characters
105);
106/* calling check_printr() to display contents of strings using print_r() */
107check_printr($strings);
108
109echo "\n*** Testing print_r() on boolean variables ***\n";
110$booleans = array (
111  TRUE,
112  FALSE,
113  true,
114  false
115);
116/* calling check_printr() to display boolean variables using print_r() */
117check_printr($booleans);
118var_dump( reset($booleans) );
119echo "\n";
120var_dump( current($booleans) );
121
122echo "\n*** Testing print_r() on array variables ***\n";
123$arrays = array (
124  array(),
125  array(NULL),
126  array(null),
127  array(true),
128  array(""),
129  array(''),
130  array(array(), array()),
131  array(array(1, 2), array('a', 'b')),
132  array(1 => 'One'),
133  array("test" => "is_array"),
134  array(0),
135  array(-1),
136  array(10.5, 5.6),
137  array("string", "test"),
138  array('string', 'test'),
139);
140/* calling check_printr() to display contents of $arrays */
141check_printr($arrays);
142
143echo "\n*** Testing print_r() on object variables ***\n";
144class object_class
145{
146  var       $value;
147  public    $public_var1 = 10;
148  private   $private_var1 = 20;
149  private   $private_var2;
150  protected $protected_var1 = "string_1";
151  protected $protected_var2;
152
153  function __construct() {
154    $this->value = 50;
155    $this->public_var2 = 11;
156    $this->private_var2 = 21;
157    $this->protected_var2 = "string_2";
158  }
159
160  public function foo1() {
161    echo "foo1() is called\n";
162  }
163  protected function foo2() {
164    echo "foo2() is called\n";
165  }
166  private function foo3() {
167    echo "foo3() is called\n";
168  }
169}
170/* class with no member */
171class no_member_class {
172 // no members
173}
174
175/* class with member as object of other class */
176class contains_object_class
177{
178   var       $p = 30;
179   var       $class_object1;
180   public    $class_object2;
181   private   $class_object3;
182   protected $class_object4;
183   var       $no_member_class_object;
184
185   public function func() {
186     echo "func() is called \n";
187   }
188
189   function __construct() {
190     $this->class_object1 = new object_class();
191     $this->class_object2 = new object_class();
192     $this->class_object3 = $this->class_object1;
193     $this->class_object4 = $this->class_object2;
194     $this->no_member_class_object = new no_member_class();
195     $this->class_object5 = $this;   //recursive reference
196   }
197}
198
199/* objects of different classes */
200$obj = new contains_object_class;
201$temp_class_obj = new object_class();
202
203/* object which is unset */
204$unset_obj = new object_class();
205unset($unset_obj);
206
207$objects = array (
208  new object_class,
209  new no_member_class,
210  new contains_object_class,
211  $obj,
212  $obj->class_object1,
213  $obj->class_object2,
214  $obj->no_member_class_object,
215  $temp_class_obj,
216  @$unset_obj
217);
218/* calling check_printr() to display contents of the objects using print_r() */
219check_printr($objects);
220
221echo "\n** Testing print_r() on objects having circular reference **\n";
222$recursion_obj1 = new object_class();
223$recursion_obj2 = new object_class();
224$recursion_obj1->obj = &$recursion_obj2;  //circular reference
225$recursion_obj2->obj = &$recursion_obj1;  //circular reference
226print_r($recursion_obj2);
227
228echo "\n*** Testing print_r() on resources ***\n";
229/* file type resource */
230$file_handle = fopen(__FILE__, "r");
231
232/* directory type resource */
233$dir_handle = opendir( __DIR__ );
234
235$resources = array (
236  $file_handle,
237  $dir_handle
238);
239/* calling check_printr() to display the resource content type
240   using print_r() */
241check_printr($resources);
242
243echo "\n*** Testing print_r() on different combinations of scalar
244            and non-scalar variables ***\n";
245/* a variable which is unset */
246$unset_var = 10.5;
247unset($unset_var);
248
249/* unset file type resource */
250unset($file_handle);
251
252$variations = array (
253  array( 123, -1.2345, "a" ),
254  array( "d", array(1, 3, 5), true, null),
255  array( new no_member_class, array(), false, 0 ),
256  array( -0.00, "Where am I?", array(7,8,9), TRUE, 'A', 987654321 ),
257  array( @$unset_var, 2.E+10, 100-20.9, 000004.599998 ),  //unusual data
258  array( "array(1,2,3,4)1.0000002TRUE", @$file_handle, 111333.00+45e5, '/00\7')
259);
260/* calling check_printr() to display combinations of scalar and
261   non-scalar variables using print_r() */
262check_printr($variations);
263
264echo "\n*** Testing print_r() on miscelleneous input arguments ***\n";
265$misc_values = array (
266  @$unset_var,
267  NULL,  // NULL argument
268  @$undef_variable,  //undefined variable
269  null
270);
271/* calling check_printr() to display miscelleneous data using print_r() */
272check_printr($misc_values);
273
274/* checking print_r() on functions */
275echo "\n*** Testing print_r() on anonymous functions ***\n";
276$newfunc = create_function('$a,$b', 'return "$a * $b = " . ($a * $b);');
277echo "New anonymous function: $newfunc\n";
278print_r( $newfunc(2, 3) );
279/* creating anonymous function dynamically */
280print_r( create_function('$a', 'return "$a * $a = " . ($a * $b);') );
281
282echo "\n\n*** Testing error conditions ***\n";
283//passing zero argument
284var_dump( print_r() );
285
286//passing more than required no. of arguments
287var_dump( print_r(123, true, "abc") );
288
289// check when second arg is given other than boolean TRUE
290var_dump( print_r ($value, "string") );
291
292/* closing resource handle used */
293closedir($dir_handle);
294
295echo "Done\n";
296?>
297--EXPECTF--
298*** Testing print_r() on integer variables ***
299
300-- Iteration 1 --
3010
3020
3030
304-- Iteration 2 --
30583
30683
30783
308-- Iteration 3 --
309123000000
310123000000
311123000000
312-- Iteration 4 --
313-83
314-83
315-83
316-- Iteration 5 --
317-12300000
318-12300000
319-12300000
320-- Iteration 6 --
321Array
322(
323    [0] => 1
324    [1] => 2
325    [2] => 3
326    [3] => 4
327    [4] => 5
328    [5] => 6
329    [6] => 7
330    [7] => 8
331    [8] => 9
332    [9] => 10
333)
334
335Array
336(
337    [0] => 1
338    [1] => 2
339    [2] => 3
340    [3] => 4
341    [4] => 5
342    [5] => 6
343    [6] => 7
344    [7] => 8
345    [8] => 9
346    [9] => 10
347)
348
349Array
350(
351    [0] => 1
352    [1] => 2
353    [2] => 3
354    [3] => 4
355    [4] => 5
356    [5] => 6
357    [6] => 7
358    [7] => 8
359    [8] => 9
360    [9] => 10
361)
362
363-- Iteration 7 --
364Array
365(
366    [0] => -1
367    [1] => -2
368    [2] => -3
369    [3] => -4
370    [4] => -5
371    [5] => -6
372    [6] => -7
373    [7] => -8
374    [8] => -9
375    [9] => -10
376)
377
378Array
379(
380    [0] => -1
381    [1] => -2
382    [2] => -3
383    [3] => -4
384    [4] => -5
385    [5] => -6
386    [6] => -7
387    [7] => -8
388    [8] => -9
389    [9] => -10
390)
391
392Array
393(
394    [0] => -1
395    [1] => -2
396    [2] => -3
397    [3] => -4
398    [4] => -5
399    [5] => -6
400    [6] => -7
401    [7] => -8
402    [8] => -9
403    [9] => -10
404)
405
406-- Iteration 8 --
4072147483647
4082147483647
4092147483647
410-- Iteration 9 --
4112147483648
4122147483648
4132147483648
414-- Iteration 10 --
415-2147483648
416-2147483648
417-2147483648
418-- Iteration 11 --
419-2147483647
420-2147483647
421-2147483647
422-- Iteration 12 --
4232147483647
4242147483647
4252147483647
426-- Iteration 13 --
427-2147483648
428-2147483648
429-2147483648
430-- Iteration 14 --
4312147483647
4322147483647
4332147483647
434-- Iteration 15 --
435-2147483648
436-2147483648
437-2147483648
438*** Testing print_r() on float variables ***
439
440-- Iteration 1 --
441-0
442-0
443-0
444-- Iteration 2 --
4450
4460
4470
448-- Iteration 3 --
4491.234
4501.234
4511.234
452-- Iteration 4 --
453-1.234
454-1.234
455-1.234
456-- Iteration 5 --
457-2
458-2
459-2
460-- Iteration 6 --
4612
4622
4632
464-- Iteration 7 --
465-0.5
466-0.5
467-0.5
468-- Iteration 8 --
4690.567
4700.567
4710.567
472-- Iteration 9 --
473-0.00067
474-0.00067
475-0.00067
476-- Iteration 10 --
477-670
478-670
479-670
480-- Iteration 11 --
481670
482670
483670
484-- Iteration 12 --
485670
486670
487670
488-- Iteration 13 --
489-0.00410003
490-0.00410003
491-0.00410003
492-- Iteration 14 --
493-4100.03
494-4100.03
495-4100.03
496-- Iteration 15 --
4970.004100003
4980.004100003
4990.004100003
500-- Iteration 16 --
5014100.003
5024100.003
5034100.003
504-- Iteration 17 --
505100000
506100000
507100000
508-- Iteration 18 --
509-100000
510-100000
511-100000
512-- Iteration 19 --
5131.0E-5
5141.0E-5
5151.0E-5
516-- Iteration 20 --
517-1.0E-5
518-1.0E-5
519-1.0E-5
520-- Iteration 21 --
521100000
522100000
523100000
524-- Iteration 22 --
525-100000
526-100000
527-100000
528-- Iteration 23 --
529100000
530100000
531100000
532-- Iteration 24 --
533-100000
534-100000
535-100000
536-- Iteration 25 --
537100000
538100000
539100000
540-- Iteration 26 --
541-100000
542-100000
543-100000
544-- Iteration 27 --
5451.0E-5
5461.0E-5
5471.0E-5
548-- Iteration 28 --
549-1.0E-5
550-1.0E-5
551-1.0E-5
552-- Iteration 29 --
553-2147483649
554-2147483649
555-2147483649
556-- Iteration 30 --
5572147483649
5582147483649
5592147483649
560-- Iteration 31 --
5612147483649
5622147483649
5632147483649
564-- Iteration 32 --
565-2147483649
566-2147483649
567-2147483649
568*** Testing print_r() on string variables ***
569
570-- Iteration 1 --
571
572
573
574-- Iteration 2 --
575
576
577
578-- Iteration 3 --
579
580
581
582-- Iteration 4 --
583
584
585
586-- Iteration 5 --
5870
5880
5890
590-- Iteration 6 --
591592593594-- Iteration 7 --
595\0
596\0
597\0
598-- Iteration 8 --
599
600
601
602-- Iteration 9 --
603\t
604\t
605\t
606-- Iteration 10 --
607PHP
608PHP
609PHP
610-- Iteration 11 --
611PHP
612PHP
613PHP
614-- Iteration 12 --
615abcd�n1234�05678�00efgh\xijkl
616abcd�n1234�05678�00efgh\xijkl
617abcd�n1234�05678�00efgh\xijkl
618-- Iteration 13 --
619abcd�efgh�ijkl�mnop�0qrst�uvwx�0yz
620abcd�efgh�ijkl�mnop�0qrst�uvwx�0yz
621abcd�efgh�ijkl�mnop�0qrst�uvwx�0yz
622-- Iteration 14 --
6231234
6245678
625	9100
625abcda
6261234
6275678
628	9100
628abcda
6291234
6305678
631	9100
631abcda
632*** Testing print_r() on boolean variables ***
633
634-- Iteration 1 --
6351
6361
6371
638-- Iteration 2 --
639
640
641
642-- Iteration 3 --
6431
6441
6451
646-- Iteration 4 --
647
648
649bool(true)
650
651bool(true)
652
653*** Testing print_r() on array variables ***
654
655-- Iteration 1 --
656Array
657(
658)
659
660Array
661(
662)
663
664Array
665(
666)
667
668-- Iteration 2 --
669Array
670(
671    [0] =>
672)
673
674Array
675(
676    [0] =>
677)
678
679Array
680(
681    [0] =>
682)
683
684-- Iteration 3 --
685Array
686(
687    [0] =>
688)
689
690Array
691(
692    [0] =>
693)
694
695Array
696(
697    [0] =>
698)
699
700-- Iteration 4 --
701Array
702(
703    [0] => 1
704)
705
706Array
707(
708    [0] => 1
709)
710
711Array
712(
713    [0] => 1
714)
715
716-- Iteration 5 --
717Array
718(
719    [0] =>
720)
721
722Array
723(
724    [0] =>
725)
726
727Array
728(
729    [0] =>
730)
731
732-- Iteration 6 --
733Array
734(
735    [0] =>
736)
737
738Array
739(
740    [0] =>
741)
742
743Array
744(
745    [0] =>
746)
747
748-- Iteration 7 --
749Array
750(
751    [0] => Array
752        (
753        )
754
755    [1] => Array
756        (
757        )
758
759)
760
761Array
762(
763    [0] => Array
764        (
765        )
766
767    [1] => Array
768        (
769        )
770
771)
772
773Array
774(
775    [0] => Array
776        (
777        )
778
779    [1] => Array
780        (
781        )
782
783)
784
785-- Iteration 8 --
786Array
787(
788    [0] => Array
789        (
790            [0] => 1
791            [1] => 2
792        )
793
794    [1] => Array
795        (
796            [0] => a
797            [1] => b
798        )
799
800)
801
802Array
803(
804    [0] => Array
805        (
806            [0] => 1
807            [1] => 2
808        )
809
810    [1] => Array
811        (
812            [0] => a
813            [1] => b
814        )
815
816)
817
818Array
819(
820    [0] => Array
821        (
822            [0] => 1
823            [1] => 2
824        )
825
826    [1] => Array
827        (
828            [0] => a
829            [1] => b
830        )
831
832)
833
834-- Iteration 9 --
835Array
836(
837    [1] => One
838)
839
840Array
841(
842    [1] => One
843)
844
845Array
846(
847    [1] => One
848)
849
850-- Iteration 10 --
851Array
852(
853    [test] => is_array
854)
855
856Array
857(
858    [test] => is_array
859)
860
861Array
862(
863    [test] => is_array
864)
865
866-- Iteration 11 --
867Array
868(
869    [0] => 0
870)
871
872Array
873(
874    [0] => 0
875)
876
877Array
878(
879    [0] => 0
880)
881
882-- Iteration 12 --
883Array
884(
885    [0] => -1
886)
887
888Array
889(
890    [0] => -1
891)
892
893Array
894(
895    [0] => -1
896)
897
898-- Iteration 13 --
899Array
900(
901    [0] => 10.5
902    [1] => 5.6
903)
904
905Array
906(
907    [0] => 10.5
908    [1] => 5.6
909)
910
911Array
912(
913    [0] => 10.5
914    [1] => 5.6
915)
916
917-- Iteration 14 --
918Array
919(
920    [0] => string
921    [1] => test
922)
923
924Array
925(
926    [0] => string
927    [1] => test
928)
929
930Array
931(
932    [0] => string
933    [1] => test
934)
935
936-- Iteration 15 --
937Array
938(
939    [0] => string
940    [1] => test
941)
942
943Array
944(
945    [0] => string
946    [1] => test
947)
948
949Array
950(
951    [0] => string
952    [1] => test
953)
954
955*** Testing print_r() on object variables ***
956
957-- Iteration 1 --
958object_class Object
959(
960    [value] => 50
961    [public_var1] => 10
962    [private_var1:object_class:private] => 20
963    [private_var2:object_class:private] => 21
964    [protected_var1:protected] => string_1
965    [protected_var2:protected] => string_2
966    [public_var2] => 11
967)
968
969object_class Object
970(
971    [value] => 50
972    [public_var1] => 10
973    [private_var1:object_class:private] => 20
974    [private_var2:object_class:private] => 21
975    [protected_var1:protected] => string_1
976    [protected_var2:protected] => string_2
977    [public_var2] => 11
978)
979
980object_class Object
981(
982    [value] => 50
983    [public_var1] => 10
984    [private_var1:object_class:private] => 20
985    [private_var2:object_class:private] => 21
986    [protected_var1:protected] => string_1
987    [protected_var2:protected] => string_2
988    [public_var2] => 11
989)
990
991-- Iteration 2 --
992no_member_class Object
993(
994)
995
996no_member_class Object
997(
998)
999
1000no_member_class Object
1001(
1002)
1003
1004-- Iteration 3 --
1005contains_object_class Object
1006(
1007    [p] => 30
1008    [class_object1] => object_class Object
1009        (
1010            [value] => 50
1011            [public_var1] => 10
1012            [private_var1:object_class:private] => 20
1013            [private_var2:object_class:private] => 21
1014            [protected_var1:protected] => string_1
1015            [protected_var2:protected] => string_2
1016            [public_var2] => 11
1017        )
1018
1019    [class_object2] => object_class Object
1020        (
1021            [value] => 50
1022            [public_var1] => 10
1023            [private_var1:object_class:private] => 20
1024            [private_var2:object_class:private] => 21
1025            [protected_var1:protected] => string_1
1026            [protected_var2:protected] => string_2
1027            [public_var2] => 11
1028        )
1029
1030    [class_object3:contains_object_class:private] => object_class Object
1031        (
1032            [value] => 50
1033            [public_var1] => 10
1034            [private_var1:object_class:private] => 20
1035            [private_var2:object_class:private] => 21
1036            [protected_var1:protected] => string_1
1037            [protected_var2:protected] => string_2
1038            [public_var2] => 11
1039        )
1040
1041    [class_object4:protected] => object_class Object
1042        (
1043            [value] => 50
1044            [public_var1] => 10
1045            [private_var1:object_class:private] => 20
1046            [private_var2:object_class:private] => 21
1047            [protected_var1:protected] => string_1
1048            [protected_var2:protected] => string_2
1049            [public_var2] => 11
1050        )
1051
1052    [no_member_class_object] => no_member_class Object
1053        (
1054        )
1055
1056    [class_object5] => contains_object_class Object
1057 *RECURSION*
1058)
1059
1060contains_object_class Object
1061(
1062    [p] => 30
1063    [class_object1] => object_class Object
1064        (
1065            [value] => 50
1066            [public_var1] => 10
1067            [private_var1:object_class:private] => 20
1068            [private_var2:object_class:private] => 21
1069            [protected_var1:protected] => string_1
1070            [protected_var2:protected] => string_2
1071            [public_var2] => 11
1072        )
1073
1074    [class_object2] => object_class Object
1075        (
1076            [value] => 50
1077            [public_var1] => 10
1078            [private_var1:object_class:private] => 20
1079            [private_var2:object_class:private] => 21
1080            [protected_var1:protected] => string_1
1081            [protected_var2:protected] => string_2
1082            [public_var2] => 11
1083        )
1084
1085    [class_object3:contains_object_class:private] => object_class Object
1086        (
1087            [value] => 50
1088            [public_var1] => 10
1089            [private_var1:object_class:private] => 20
1090            [private_var2:object_class:private] => 21
1091            [protected_var1:protected] => string_1
1092            [protected_var2:protected] => string_2
1093            [public_var2] => 11
1094        )
1095
1096    [class_object4:protected] => object_class Object
1097        (
1098            [value] => 50
1099            [public_var1] => 10
1100            [private_var1:object_class:private] => 20
1101            [private_var2:object_class:private] => 21
1102            [protected_var1:protected] => string_1
1103            [protected_var2:protected] => string_2
1104            [public_var2] => 11
1105        )
1106
1107    [no_member_class_object] => no_member_class Object
1108        (
1109        )
1110
1111    [class_object5] => contains_object_class Object
1112 *RECURSION*
1113)
1114
1115contains_object_class Object
1116(
1117    [p] => 30
1118    [class_object1] => object_class Object
1119        (
1120            [value] => 50
1121            [public_var1] => 10
1122            [private_var1:object_class:private] => 20
1123            [private_var2:object_class:private] => 21
1124            [protected_var1:protected] => string_1
1125            [protected_var2:protected] => string_2
1126            [public_var2] => 11
1127        )
1128
1129    [class_object2] => object_class Object
1130        (
1131            [value] => 50
1132            [public_var1] => 10
1133            [private_var1:object_class:private] => 20
1134            [private_var2:object_class:private] => 21
1135            [protected_var1:protected] => string_1
1136            [protected_var2:protected] => string_2
1137            [public_var2] => 11
1138        )
1139
1140    [class_object3:contains_object_class:private] => object_class Object
1141        (
1142            [value] => 50
1143            [public_var1] => 10
1144            [private_var1:object_class:private] => 20
1145            [private_var2:object_class:private] => 21
1146            [protected_var1:protected] => string_1
1147            [protected_var2:protected] => string_2
1148            [public_var2] => 11
1149        )
1150
1151    [class_object4:protected] => object_class Object
1152        (
1153            [value] => 50
1154            [public_var1] => 10
1155            [private_var1:object_class:private] => 20
1156            [private_var2:object_class:private] => 21
1157            [protected_var1:protected] => string_1
1158            [protected_var2:protected] => string_2
1159            [public_var2] => 11
1160        )
1161
1162    [no_member_class_object] => no_member_class Object
1163        (
1164        )
1165
1166    [class_object5] => contains_object_class Object
1167 *RECURSION*
1168)
1169
1170-- Iteration 4 --
1171contains_object_class Object
1172(
1173    [p] => 30
1174    [class_object1] => object_class Object
1175        (
1176            [value] => 50
1177            [public_var1] => 10
1178            [private_var1:object_class:private] => 20
1179            [private_var2:object_class:private] => 21
1180            [protected_var1:protected] => string_1
1181            [protected_var2:protected] => string_2
1182            [public_var2] => 11
1183        )
1184
1185    [class_object2] => object_class Object
1186        (
1187            [value] => 50
1188            [public_var1] => 10
1189            [private_var1:object_class:private] => 20
1190            [private_var2:object_class:private] => 21
1191            [protected_var1:protected] => string_1
1192            [protected_var2:protected] => string_2
1193            [public_var2] => 11
1194        )
1195
1196    [class_object3:contains_object_class:private] => object_class Object
1197        (
1198            [value] => 50
1199            [public_var1] => 10
1200            [private_var1:object_class:private] => 20
1201            [private_var2:object_class:private] => 21
1202            [protected_var1:protected] => string_1
1203            [protected_var2:protected] => string_2
1204            [public_var2] => 11
1205        )
1206
1207    [class_object4:protected] => object_class Object
1208        (
1209            [value] => 50
1210            [public_var1] => 10
1211            [private_var1:object_class:private] => 20
1212            [private_var2:object_class:private] => 21
1213            [protected_var1:protected] => string_1
1214            [protected_var2:protected] => string_2
1215            [public_var2] => 11
1216        )
1217
1218    [no_member_class_object] => no_member_class Object
1219        (
1220        )
1221
1222    [class_object5] => contains_object_class Object
1223 *RECURSION*
1224)
1225
1226contains_object_class Object
1227(
1228    [p] => 30
1229    [class_object1] => object_class Object
1230        (
1231            [value] => 50
1232            [public_var1] => 10
1233            [private_var1:object_class:private] => 20
1234            [private_var2:object_class:private] => 21
1235            [protected_var1:protected] => string_1
1236            [protected_var2:protected] => string_2
1237            [public_var2] => 11
1238        )
1239
1240    [class_object2] => object_class Object
1241        (
1242            [value] => 50
1243            [public_var1] => 10
1244            [private_var1:object_class:private] => 20
1245            [private_var2:object_class:private] => 21
1246            [protected_var1:protected] => string_1
1247            [protected_var2:protected] => string_2
1248            [public_var2] => 11
1249        )
1250
1251    [class_object3:contains_object_class:private] => object_class Object
1252        (
1253            [value] => 50
1254            [public_var1] => 10
1255            [private_var1:object_class:private] => 20
1256            [private_var2:object_class:private] => 21
1257            [protected_var1:protected] => string_1
1258            [protected_var2:protected] => string_2
1259            [public_var2] => 11
1260        )
1261
1262    [class_object4:protected] => object_class Object
1263        (
1264            [value] => 50
1265            [public_var1] => 10
1266            [private_var1:object_class:private] => 20
1267            [private_var2:object_class:private] => 21
1268            [protected_var1:protected] => string_1
1269            [protected_var2:protected] => string_2
1270            [public_var2] => 11
1271        )
1272
1273    [no_member_class_object] => no_member_class Object
1274        (
1275        )
1276
1277    [class_object5] => contains_object_class Object
1278 *RECURSION*
1279)
1280
1281contains_object_class Object
1282(
1283    [p] => 30
1284    [class_object1] => object_class Object
1285        (
1286            [value] => 50
1287            [public_var1] => 10
1288            [private_var1:object_class:private] => 20
1289            [private_var2:object_class:private] => 21
1290            [protected_var1:protected] => string_1
1291            [protected_var2:protected] => string_2
1292            [public_var2] => 11
1293        )
1294
1295    [class_object2] => object_class Object
1296        (
1297            [value] => 50
1298            [public_var1] => 10
1299            [private_var1:object_class:private] => 20
1300            [private_var2:object_class:private] => 21
1301            [protected_var1:protected] => string_1
1302            [protected_var2:protected] => string_2
1303            [public_var2] => 11
1304        )
1305
1306    [class_object3:contains_object_class:private] => object_class Object
1307        (
1308            [value] => 50
1309            [public_var1] => 10
1310            [private_var1:object_class:private] => 20
1311            [private_var2:object_class:private] => 21
1312            [protected_var1:protected] => string_1
1313            [protected_var2:protected] => string_2
1314            [public_var2] => 11
1315        )
1316
1317    [class_object4:protected] => object_class Object
1318        (
1319            [value] => 50
1320            [public_var1] => 10
1321            [private_var1:object_class:private] => 20
1322            [private_var2:object_class:private] => 21
1323            [protected_var1:protected] => string_1
1324            [protected_var2:protected] => string_2
1325            [public_var2] => 11
1326        )
1327
1328    [no_member_class_object] => no_member_class Object
1329        (
1330        )
1331
1332    [class_object5] => contains_object_class Object
1333 *RECURSION*
1334)
1335
1336-- Iteration 5 --
1337object_class Object
1338(
1339    [value] => 50
1340    [public_var1] => 10
1341    [private_var1:object_class:private] => 20
1342    [private_var2:object_class:private] => 21
1343    [protected_var1:protected] => string_1
1344    [protected_var2:protected] => string_2
1345    [public_var2] => 11
1346)
1347
1348object_class Object
1349(
1350    [value] => 50
1351    [public_var1] => 10
1352    [private_var1:object_class:private] => 20
1353    [private_var2:object_class:private] => 21
1354    [protected_var1:protected] => string_1
1355    [protected_var2:protected] => string_2
1356    [public_var2] => 11
1357)
1358
1359object_class Object
1360(
1361    [value] => 50
1362    [public_var1] => 10
1363    [private_var1:object_class:private] => 20
1364    [private_var2:object_class:private] => 21
1365    [protected_var1:protected] => string_1
1366    [protected_var2:protected] => string_2
1367    [public_var2] => 11
1368)
1369
1370-- Iteration 6 --
1371object_class Object
1372(
1373    [value] => 50
1374    [public_var1] => 10
1375    [private_var1:object_class:private] => 20
1376    [private_var2:object_class:private] => 21
1377    [protected_var1:protected] => string_1
1378    [protected_var2:protected] => string_2
1379    [public_var2] => 11
1380)
1381
1382object_class Object
1383(
1384    [value] => 50
1385    [public_var1] => 10
1386    [private_var1:object_class:private] => 20
1387    [private_var2:object_class:private] => 21
1388    [protected_var1:protected] => string_1
1389    [protected_var2:protected] => string_2
1390    [public_var2] => 11
1391)
1392
1393object_class Object
1394(
1395    [value] => 50
1396    [public_var1] => 10
1397    [private_var1:object_class:private] => 20
1398    [private_var2:object_class:private] => 21
1399    [protected_var1:protected] => string_1
1400    [protected_var2:protected] => string_2
1401    [public_var2] => 11
1402)
1403
1404-- Iteration 7 --
1405no_member_class Object
1406(
1407)
1408
1409no_member_class Object
1410(
1411)
1412
1413no_member_class Object
1414(
1415)
1416
1417-- Iteration 8 --
1418object_class Object
1419(
1420    [value] => 50
1421    [public_var1] => 10
1422    [private_var1:object_class:private] => 20
1423    [private_var2:object_class:private] => 21
1424    [protected_var1:protected] => string_1
1425    [protected_var2:protected] => string_2
1426    [public_var2] => 11
1427)
1428
1429object_class Object
1430(
1431    [value] => 50
1432    [public_var1] => 10
1433    [private_var1:object_class:private] => 20
1434    [private_var2:object_class:private] => 21
1435    [protected_var1:protected] => string_1
1436    [protected_var2:protected] => string_2
1437    [public_var2] => 11
1438)
1439
1440object_class Object
1441(
1442    [value] => 50
1443    [public_var1] => 10
1444    [private_var1:object_class:private] => 20
1445    [private_var2:object_class:private] => 21
1446    [protected_var1:protected] => string_1
1447    [protected_var2:protected] => string_2
1448    [public_var2] => 11
1449)
1450
1451-- Iteration 9 --
1452
1453
1454
1455** Testing print_r() on objects having circular reference **
1456object_class Object
1457(
1458    [value] => 50
1459    [public_var1] => 10
1460    [private_var1:object_class:private] => 20
1461    [private_var2:object_class:private] => 21
1462    [protected_var1:protected] => string_1
1463    [protected_var2:protected] => string_2
1464    [public_var2] => 11
1465    [obj] => object_class Object
1466        (
1467            [value] => 50
1468            [public_var1] => 10
1469            [private_var1:object_class:private] => 20
1470            [private_var2:object_class:private] => 21
1471            [protected_var1:protected] => string_1
1472            [protected_var2:protected] => string_2
1473            [public_var2] => 11
1474            [obj] => object_class Object
1475 *RECURSION*
1476        )
1477
1478)
1479
1480*** Testing print_r() on resources ***
1481
1482-- Iteration 1 --
1483Resource id #%d
1484Resource id #%d
1485Resource id #%d
1486-- Iteration 2 --
1487Resource id #%d
1488Resource id #%d
1489Resource id #%d
1490*** Testing print_r() on different combinations of scalar
1491            and non-scalar variables ***
1492
1493-- Iteration 1 --
1494Array
1495(
1496    [0] => 123
1497    [1] => -1.2345
1498    [2] => a
1499)
1500
1501Array
1502(
1503    [0] => 123
1504    [1] => -1.2345
1505    [2] => a
1506)
1507
1508Array
1509(
1510    [0] => 123
1511    [1] => -1.2345
1512    [2] => a
1513)
1514
1515-- Iteration 2 --
1516Array
1517(
1518    [0] => d
1519    [1] => Array
1520        (
1521            [0] => 1
1522            [1] => 3
1523            [2] => 5
1524        )
1525
1526    [2] => 1
1527    [3] =>
1528)
1529
1530Array
1531(
1532    [0] => d
1533    [1] => Array
1534        (
1535            [0] => 1
1536            [1] => 3
1537            [2] => 5
1538        )
1539
1540    [2] => 1
1541    [3] =>
1542)
1543
1544Array
1545(
1546    [0] => d
1547    [1] => Array
1548        (
1549            [0] => 1
1550            [1] => 3
1551            [2] => 5
1552        )
1553
1554    [2] => 1
1555    [3] =>
1556)
1557
1558-- Iteration 3 --
1559Array
1560(
1561    [0] => no_member_class Object
1562        (
1563        )
1564
1565    [1] => Array
1566        (
1567        )
1568
1569    [2] =>
1570    [3] => 0
1571)
1572
1573Array
1574(
1575    [0] => no_member_class Object
1576        (
1577        )
1578
1579    [1] => Array
1580        (
1581        )
1582
1583    [2] =>
1584    [3] => 0
1585)
1586
1587Array
1588(
1589    [0] => no_member_class Object
1590        (
1591        )
1592
1593    [1] => Array
1594        (
1595        )
1596
1597    [2] =>
1598    [3] => 0
1599)
1600
1601-- Iteration 4 --
1602Array
1603(
1604    [0] => -0
1605    [1] => Where am I?
1606    [2] => Array
1607        (
1608            [0] => 7
1609            [1] => 8
1610            [2] => 9
1611        )
1612
1613    [3] => 1
1614    [4] => A
1615    [5] => 987654321
1616)
1617
1618Array
1619(
1620    [0] => -0
1621    [1] => Where am I?
1622    [2] => Array
1623        (
1624            [0] => 7
1625            [1] => 8
1626            [2] => 9
1627        )
1628
1629    [3] => 1
1630    [4] => A
1631    [5] => 987654321
1632)
1633
1634Array
1635(
1636    [0] => -0
1637    [1] => Where am I?
1638    [2] => Array
1639        (
1640            [0] => 7
1641            [1] => 8
1642            [2] => 9
1643        )
1644
1645    [3] => 1
1646    [4] => A
1647    [5] => 987654321
1648)
1649
1650-- Iteration 5 --
1651Array
1652(
1653    [0] =>
1654    [1] => 20000000000
1655    [2] => 79.1
1656    [3] => 4.599998
1657)
1658
1659Array
1660(
1661    [0] =>
1662    [1] => 20000000000
1663    [2] => 79.1
1664    [3] => 4.599998
1665)
1666
1667Array
1668(
1669    [0] =>
1670    [1] => 20000000000
1671    [2] => 79.1
1672    [3] => 4.599998
1673)
1674
1675-- Iteration 6 --
1676Array
1677(
1678    [0] => array(1,2,3,4)1.0000002TRUE
1679    [1] =>
1680    [2] => 4611333
1681    [3] => /00\7
1682)
1683
1684Array
1685(
1686    [0] => array(1,2,3,4)1.0000002TRUE
1687    [1] =>
1688    [2] => 4611333
1689    [3] => /00\7
1690)
1691
1692Array
1693(
1694    [0] => array(1,2,3,4)1.0000002TRUE
1695    [1] =>
1696    [2] => 4611333
1697    [3] => /00\7
1698)
1699
1700*** Testing print_r() on miscelleneous input arguments ***
1701
1702-- Iteration 1 --
1703
1704
1705
1706-- Iteration 2 --
1707
1708
1709
1710-- Iteration 3 --
1711
1712
1713
1714-- Iteration 4 --
1715
1716
1717
1718*** Testing print_r() on anonymous functions ***
1719
1720Deprecated: Function create_function() is deprecated in %s on line %d
1721New anonymous function: �lambda_1
17222 * 3 = 6
1723Deprecated: Function create_function() is deprecated in %s on line %d
1724�lambda_2
1725
1726*** Testing error conditions ***
1727
1728Warning: print_r() expects at least 1 parameter, 0 given in %s on line %d
1729bool(false)
1730
1731Warning: print_r() expects at most 2 parameters, 3 given in %s on line %d
1732bool(false)
1733
1734Notice: Undefined variable: value in %s on line %d
1735string(0) ""
1736Done
1737