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