1--TEST-- 2Test unset(), empty() and isset() functions 3--FILE-- 4<?php 5/* Prototype: void unset ( mixed $var [, mixed $var [, mixed $...]] ); 6 Description: unset() destroys the specified variables 7 8 Prototype: bool empty( mixed $var ); 9 Description: Determine whether a variable is considered to be empty 10 11 Prototype: bool isset ( mixed $var [, mixed $var [, $...]] ); 12 Description: Returns TRUE if var exists; FALSE otherwise 13*/ 14 15echo "*** Testing unset(), empty() & isset() with scalar variables ***\n"; 16 17// testing scalar variables 18$scalar_variables = array( 19 0, 20 1, 21 +1 22 -1, 23 0x55, 24 -0xFA, 25 0123, 26 -0563, 27 0.0, 28 1e5, 29 1E-5, 30 -1.5e5, 31 +5.6, 32 "", 33 '', 34 " ", 35 ' ', 36 "string", 37 "123", 38 "0", 39 "ture", 40 "FALSE", 41 "NULL", 42 "null", 43 true, 44 false, 45 TRUE, 46 FALSE 47); 48 49$loop_counter = 1; 50foreach ($scalar_variables as $scalar_var) { 51 $set_var = 10; // this variable to use with isset 52 echo "-- Iteration $loop_counter --\n"; $loop_counter++; 53 54 // checking with isset before unsetting, expected: bool(true) 55 var_dump( isset($scalar_var) ); 56 var_dump( isset($scalar_var, $set_var) ); 57 // checking if the var is empty, expected: bool(false) on most 58 // except "", 0, "0", NULL, FALSE 59 var_dump( empty($scalar_var) ); 60 61 // destroy the variable using unset 62 unset( $scalar_var ); 63 // dump and see if its destroyed, expcted: NULL 64 var_dump( $scalar_var ); 65 66 // check using isset to see if unset, expected: bool(false) 67 var_dump( isset($scalar_var) ); 68 var_dump( isset($scalar_var, $set_var) ); 69 70 // empty to check if empty, expecting bool(true) 71 var_dump( empty($scalar_var) ); 72 73 // isset() with two args, one arg only unset, expected: bool(false) 74 var_dump( isset($scalar_var, $set_var) ); 75 76 // isset() with two args, both args already unset, expected: bool(false); 77 unset($set_var); 78 var_dump( isset($scalar_var, $set_var) ); 79} 80 81echo "\n*** Testing unset(), empty() & isset() with arrays ***\n"; 82$array_variables = array( 83 array(), 84 array(NULL), 85 array(0), 86 array("0"), 87 array(""), 88 array(1,2,3,4), 89 array(1.4,2.5,5.6), 90 array(1 => "One", 2 => "two"), 91 array("Name" => "Jack", "Age" => "30"), 92 array(1,2, "One" => "1", 2 => "two", ""=>"empty", "" => '') 93); 94 95$outer_loop_counter = 1; 96foreach ($array_variables as $array_var) { 97 echo "--- Outerloop Iteration $outer_loop_counter ---\n"; 98 99 // check the isset and unset on non existing key 100 $var = 1; // a var which is defined 101 // try to unset the element which is non-existent 102 unset($array_var['non_existent']); 103 // check using isset() & empty() on a non_existent element in the array 104 var_dump( isset($array_var['non_existent']) ); 105 var_dump( isset($array_var['non_existent'], $var) ); 106 var_dump( isset($array_var['non_existent'], $array_var['none']) ); 107 var_dump( empty($array_var['non_existent']) ); 108 109 // testing empty and isset on arrays 110 var_dump( empty($array_var) ); // expecting bool(false), except: array(), which is considered empty 111 var_dump( isset($array_var) ); // expecting bool(true), except: array(), which is not set 112 113 // get the keys of the $array_var 114 $keys = array_keys($array_var); 115 // unset each element in the array and see the working of unset, isset & empty 116 $inner_loop_counter = 1; 117 foreach ($keys as $key_value) { 118 echo "-- Innerloop Iteration $inner_loop_counter of Outerloop Iteration $outer_loop_counter --\n"; 119 $inner_loop_counter++; 120 121 // unset the element 122 unset($array_var[$key_value]); 123 // dump the array after element was unset 124 var_dump($array_var); 125 // check using isset for the element that was unset 126 var_dump( isset($array_var[$key_val]) ); // expected: bool(false) 127 // calling isset with more args 128 var_dump( isset($array_var[$key_val], $array_var) ); //expected: bool(false) 129 130 // calling empty, expected bool(true) 131 var_dump( empty($array_var[$key_val]) ); 132 133 // dump the array to see that that array did not get modified 134 // because of using isset, empty and unset on its element 135 var_dump($array_var); 136 } 137 138 $outer_loop_counter++; 139 140 // unset the whole array 141 unset($array_var); 142 // dump the array to see its unset 143 var_dump($array_var); 144 // use isset to see that array is not set 145 var_dump( isset($array_var) ); //expected: bool(false) 146 var_dump( isset($array_var, $array_var[$key_val]) ); // expected: bool(false) 147 148 // empty() to see if the array is empty 149 var_dump( empty($array_var) ); // expected: bool(true) 150} 151 152echo "\n*** Testing unset(), emtpy() & isset() with resource variables ***\n"; 153$fp = fopen(__FILE__, "r"); 154$dfp = opendir( dirname(__FILE__) ); 155$resources = array ( 156 $fp, 157 $dfp 158); 159$loop_counter = 1; 160foreach ($resources as $resource) { 161 $temp_var = 10; 162 echo "-- Iteration $loop_counter --\n"; $loop_counter++; 163 //dump the resource first 164 var_dump($resource); 165 166 // check using isset() and empty() 167 var_dump( isset($resource) ); // expected: bool(true) 168 var_dump( empty($resource) ); // expected: bool(false) 169 // call isset() with two args, both set 170 var_dump( isset($resource, $temp_var) ); // expected: bool(true) 171 172 // dump the resource to see using isset() and empty () had no effect on it 173 var_dump($resource); 174 175 // unset the resource 176 unset($resource); 177 // check using isset() and empty() 178 var_dump( isset($resource) ); // expected: bool(flase) 179 var_dump( empty($resource) ); // expected: bool(true) 180 // call isset() with two args, but one set 181 var_dump( isset($resource, $temp_var) ); // expected: bool(false) 182 // uset the temp_var 183 unset($temp_var); 184 // now the isset() with both the args as unset 185 var_dump( isset($resource, $temp_var) ); // expected: bool(false); 186 187 // dump the resource to see if there any effect on it 188 var_dump($resource); 189} 190// unset and dump the array containing all the resources to see that 191// unset works correctly 192unset($resources); 193var_dump($resources); 194var_dump( isset($resources) ); //expected: bool(false) 195var_dump( empty($resources) ); // expected: bool(true) 196 197echo "\n*** Testing unset(), empty() & isset() with objects ***\n"; 198class Point 199{ 200 var $x; 201 var $y; 202 var $lable; 203 204 function Point($x, $y) { 205 $this->x = $x; 206 $this->y = $y; 207 } 208 209 function setLable($lable) { 210 $this->lable = $lable; 211 } 212 function testPoint() { 213 echo "\nPoint::testPoint() called\n"; 214 } 215} 216$point1 = new Point(30,40); 217 218// use unset/empty/isset to check the object 219var_dump($point1); // dump the object 220 221// check the object and member that is not set 222var_dump( isset($point1) ); // expected: bool(true) 223var_dump( empty($point1) ); // expected: bool(false) 224var_dump( isset($point1->$lable) ); //expected: bool(flase) 225var_dump( empty($point1->$lable) ); //expected: bool(true) 226 227//set the member variable lable and check 228$point1->setLable("Point1"); 229var_dump( isset($point1->$lable) ); //expected: bool(true) 230var_dump( empty($point1->$lable) ); //expected: bool(false) 231 232// dump the object to see that obj was not harmed 233// because of the usage of the isset & empty 234var_dump($point1); 235 236//unset a member and check 237unset($point1->x); 238// dump the point to see that variable was unset 239var_dump($point1); 240var_dump( isset($point1->x) ); // expected: bool(false) 241var_dump( empty($point1->x) ); // expected: bool(true) 242 243// unset all members and check 244unset($point1->y); 245unset($point1->lable); 246// dump the objec to check that all variables are unset 247var_dump($point1); 248var_dump( isset($point1) ); // expected: bool(ture) 249var_dump( empty($point1) ); // expected: bool(false) 250 251//unset the object and check 252unset($point1); 253var_dump( isset($point1) ); // expected: bool(false) 254var_dump( empty($point1) ); // expected: bool(true) 255// dump to see that object is unset 256var_dump($point1); 257 258// try isset/unset/empty on a member function 259$point2 = new Point(5,6); 260var_dump( isset($point2->testPoint) ); 261var_dump( empty($point2->testPoint) ); 262unset($point2->testPoint); 263var_dump( isset($point2->testPoint) ); 264var_dump( empty($point2->testPoint) ); 265 266// use get_class_methods to see effect if any 267var_dump( get_class_methods($point2) ); 268// dump the object to see the effect, none expected 269var_dump($point2); 270 271/* testing variation in operation for isset(), empty() & unset(). 272Note: Most of the variation for function unset() is testing by a 273 set of testcases named "Zend/tests/unset_cv??.phpt", only 274 variation not tested are attempted here */ 275 276echo "\n*** Testing possible variation in operation for isset(), empty() & unset() ***\n"; 277/* unset() variation1: checking unset on static variable inside a function. 278 * unset() destroys the variable only in the context of the rest of a function 279 * Following calls will restore the previous value of a variable. 280 */ 281echo "\n** Testing unset() variation 1: unset on static variable inside a function **\n"; 282function test_unset1() { 283 static $static_var; 284 285 // increment the value of the static. this change is in function context 286 $static_var ++; 287 288 echo "value of static_var before unset: $static_var\n"; 289 // check using isset and empty 290 var_dump( isset($static_var) ); 291 var_dump( empty($static_var) ); 292 293 // unset the static var 294 unset($static_var); 295 echo "value of static_var after unset: $static_var\n"; 296 // check using isset and empty 297 var_dump( isset($static_var) ); 298 var_dump( empty($static_var) ); 299 300 // assign a value to static var 301 $static_var = 20; 302 echo "value of static_var after new assignment: $static_var\n"; 303} 304// call the functiont 305test_unset1(); 306test_unset1(); 307test_unset1(); 308 309 310echo "\n** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **\n"; 311/* unset() variation2: Pass by reference 312 * If a variable that is PASSED BY REFERENCE is unset() inside of a function, 313 * only the local variable is destroyed. The variable in the calling environment 314 * will retain the same value as before unset() was called. 315 */ 316function test_unset2( &$ref_val ) { 317 // unset the variable passed 318 unset($ref_val); 319 // check using isset and empty to confirm 320 var_dump( isset($ref_val) ); 321 var_dump( empty($ref_val) ); 322 323 // set the value ot a new one 324 $ref_val = "new value by ref"; 325} 326 327$value = "value"; 328var_dump($value); 329test_unset2($value); 330var_dump($value); 331 332 333echo "\n** Testing unset() variation 3: unset on a global variable inside of a function **\n"; 334/* unset() variation2: unset on a global variable inside a function 335 * If a globalized variable is unset() inside of a function, only the 336 * local variable is destroyed. The variable in the calling environment 337 * will retain the same value as before unset() was called. 338 */ 339$global_var = 10; 340 341function test_unset3() { 342 global $global_var; 343 344 // check the $global_var using isset and empty 345 var_dump( isset($global_var) ); 346 var_dump( empty($global_var) ); 347 348 // unset the global var 349 unset($global_var); 350 351 // check the $global_var using isset and empty 352 var_dump( isset($global_var) ); 353 var_dump( empty($global_var) ); 354} 355 356var_dump($global_var); 357test_unset3(); 358var_dump($global_var); 359 360//Note: No error conditions relating to passing arguments can be tested 361// because these are not functions but statements, it will result in syntax error. 362?> 363===DONE=== 364--EXPECTF-- 365*** Testing unset(), empty() & isset() with scalar variables *** 366-- Iteration 1 -- 367bool(true) 368bool(true) 369bool(true) 370 371Notice: Undefined variable: scalar_var in %s on line %d 372NULL 373bool(false) 374bool(false) 375bool(true) 376bool(false) 377bool(false) 378-- Iteration 2 -- 379bool(true) 380bool(true) 381bool(false) 382 383Notice: Undefined variable: scalar_var in %s on line %d 384NULL 385bool(false) 386bool(false) 387bool(true) 388bool(false) 389bool(false) 390-- Iteration 3 -- 391bool(true) 392bool(true) 393bool(true) 394 395Notice: Undefined variable: scalar_var in %s on line %d 396NULL 397bool(false) 398bool(false) 399bool(true) 400bool(false) 401bool(false) 402-- Iteration 4 -- 403bool(true) 404bool(true) 405bool(false) 406 407Notice: Undefined variable: scalar_var in %s on line %d 408NULL 409bool(false) 410bool(false) 411bool(true) 412bool(false) 413bool(false) 414-- Iteration 5 -- 415bool(true) 416bool(true) 417bool(false) 418 419Notice: Undefined variable: scalar_var in %s on line %d 420NULL 421bool(false) 422bool(false) 423bool(true) 424bool(false) 425bool(false) 426-- Iteration 6 -- 427bool(true) 428bool(true) 429bool(false) 430 431Notice: Undefined variable: scalar_var in %s on line %d 432NULL 433bool(false) 434bool(false) 435bool(true) 436bool(false) 437bool(false) 438-- Iteration 7 -- 439bool(true) 440bool(true) 441bool(false) 442 443Notice: Undefined variable: scalar_var in %s on line %d 444NULL 445bool(false) 446bool(false) 447bool(true) 448bool(false) 449bool(false) 450-- Iteration 8 -- 451bool(true) 452bool(true) 453bool(true) 454 455Notice: Undefined variable: scalar_var in %s on line %d 456NULL 457bool(false) 458bool(false) 459bool(true) 460bool(false) 461bool(false) 462-- Iteration 9 -- 463bool(true) 464bool(true) 465bool(false) 466 467Notice: Undefined variable: scalar_var in %s on line %d 468NULL 469bool(false) 470bool(false) 471bool(true) 472bool(false) 473bool(false) 474-- Iteration 10 -- 475bool(true) 476bool(true) 477bool(false) 478 479Notice: Undefined variable: scalar_var in %s on line %d 480NULL 481bool(false) 482bool(false) 483bool(true) 484bool(false) 485bool(false) 486-- Iteration 11 -- 487bool(true) 488bool(true) 489bool(false) 490 491Notice: Undefined variable: scalar_var in %s on line %d 492NULL 493bool(false) 494bool(false) 495bool(true) 496bool(false) 497bool(false) 498-- Iteration 12 -- 499bool(true) 500bool(true) 501bool(false) 502 503Notice: Undefined variable: scalar_var in %s on line %d 504NULL 505bool(false) 506bool(false) 507bool(true) 508bool(false) 509bool(false) 510-- Iteration 13 -- 511bool(true) 512bool(true) 513bool(true) 514 515Notice: Undefined variable: scalar_var in %s on line %d 516NULL 517bool(false) 518bool(false) 519bool(true) 520bool(false) 521bool(false) 522-- Iteration 14 -- 523bool(true) 524bool(true) 525bool(true) 526 527Notice: Undefined variable: scalar_var in %s on line %d 528NULL 529bool(false) 530bool(false) 531bool(true) 532bool(false) 533bool(false) 534-- Iteration 15 -- 535bool(true) 536bool(true) 537bool(false) 538 539Notice: Undefined variable: scalar_var in %s on line %d 540NULL 541bool(false) 542bool(false) 543bool(true) 544bool(false) 545bool(false) 546-- Iteration 16 -- 547bool(true) 548bool(true) 549bool(false) 550 551Notice: Undefined variable: scalar_var in %s on line %d 552NULL 553bool(false) 554bool(false) 555bool(true) 556bool(false) 557bool(false) 558-- Iteration 17 -- 559bool(true) 560bool(true) 561bool(false) 562 563Notice: Undefined variable: scalar_var in %s on line %d 564NULL 565bool(false) 566bool(false) 567bool(true) 568bool(false) 569bool(false) 570-- Iteration 18 -- 571bool(true) 572bool(true) 573bool(false) 574 575Notice: Undefined variable: scalar_var in %s on line %d 576NULL 577bool(false) 578bool(false) 579bool(true) 580bool(false) 581bool(false) 582-- Iteration 19 -- 583bool(true) 584bool(true) 585bool(true) 586 587Notice: Undefined variable: scalar_var in %s on line %d 588NULL 589bool(false) 590bool(false) 591bool(true) 592bool(false) 593bool(false) 594-- Iteration 20 -- 595bool(true) 596bool(true) 597bool(false) 598 599Notice: Undefined variable: scalar_var in %s on line %d 600NULL 601bool(false) 602bool(false) 603bool(true) 604bool(false) 605bool(false) 606-- Iteration 21 -- 607bool(true) 608bool(true) 609bool(false) 610 611Notice: Undefined variable: scalar_var in %s on line %d 612NULL 613bool(false) 614bool(false) 615bool(true) 616bool(false) 617bool(false) 618-- Iteration 22 -- 619bool(true) 620bool(true) 621bool(false) 622 623Notice: Undefined variable: scalar_var in %s on line %d 624NULL 625bool(false) 626bool(false) 627bool(true) 628bool(false) 629bool(false) 630-- Iteration 23 -- 631bool(true) 632bool(true) 633bool(false) 634 635Notice: Undefined variable: scalar_var in %s on line %d 636NULL 637bool(false) 638bool(false) 639bool(true) 640bool(false) 641bool(false) 642-- Iteration 24 -- 643bool(true) 644bool(true) 645bool(false) 646 647Notice: Undefined variable: scalar_var in %s on line %d 648NULL 649bool(false) 650bool(false) 651bool(true) 652bool(false) 653bool(false) 654-- Iteration 25 -- 655bool(true) 656bool(true) 657bool(true) 658 659Notice: Undefined variable: scalar_var in %s on line %d 660NULL 661bool(false) 662bool(false) 663bool(true) 664bool(false) 665bool(false) 666-- Iteration 26 -- 667bool(true) 668bool(true) 669bool(false) 670 671Notice: Undefined variable: scalar_var in %s on line %d 672NULL 673bool(false) 674bool(false) 675bool(true) 676bool(false) 677bool(false) 678-- Iteration 27 -- 679bool(true) 680bool(true) 681bool(true) 682 683Notice: Undefined variable: scalar_var in %s on line %d 684NULL 685bool(false) 686bool(false) 687bool(true) 688bool(false) 689bool(false) 690 691*** Testing unset(), empty() & isset() with arrays *** 692--- Outerloop Iteration 1 --- 693bool(false) 694bool(false) 695bool(false) 696bool(true) 697bool(true) 698bool(true) 699 700Notice: Undefined variable: array_var in %s on line %d 701NULL 702bool(false) 703bool(false) 704bool(true) 705--- Outerloop Iteration 2 --- 706bool(false) 707bool(false) 708bool(false) 709bool(true) 710bool(false) 711bool(true) 712-- Innerloop Iteration 1 of Outerloop Iteration 2 -- 713array(0) { 714} 715 716Notice: Undefined variable: key_val in %s on line %d 717bool(false) 718 719Notice: Undefined variable: key_val in %s on line %d 720bool(false) 721 722Notice: Undefined variable: key_val in %s on line %d 723bool(true) 724array(0) { 725} 726 727Notice: Undefined variable: array_var in %s on line %d 728NULL 729bool(false) 730bool(false) 731bool(true) 732--- Outerloop Iteration 3 --- 733bool(false) 734bool(false) 735bool(false) 736bool(true) 737bool(false) 738bool(true) 739-- Innerloop Iteration 1 of Outerloop Iteration 3 -- 740array(0) { 741} 742 743Notice: Undefined variable: key_val in %s on line %d 744bool(false) 745 746Notice: Undefined variable: key_val in %s on line %d 747bool(false) 748 749Notice: Undefined variable: key_val in %s on line %d 750bool(true) 751array(0) { 752} 753 754Notice: Undefined variable: array_var in %s on line %d 755NULL 756bool(false) 757bool(false) 758bool(true) 759--- Outerloop Iteration 4 --- 760bool(false) 761bool(false) 762bool(false) 763bool(true) 764bool(false) 765bool(true) 766-- Innerloop Iteration 1 of Outerloop Iteration 4 -- 767array(0) { 768} 769 770Notice: Undefined variable: key_val in %s on line %d 771bool(false) 772 773Notice: Undefined variable: key_val in %s on line %d 774bool(false) 775 776Notice: Undefined variable: key_val in %s on line %d 777bool(true) 778array(0) { 779} 780 781Notice: Undefined variable: array_var in %s on line %d 782NULL 783bool(false) 784bool(false) 785bool(true) 786--- Outerloop Iteration 5 --- 787bool(false) 788bool(false) 789bool(false) 790bool(true) 791bool(false) 792bool(true) 793-- Innerloop Iteration 1 of Outerloop Iteration 5 -- 794array(0) { 795} 796 797Notice: Undefined variable: key_val in %s on line %d 798bool(false) 799 800Notice: Undefined variable: key_val in %s on line %d 801bool(false) 802 803Notice: Undefined variable: key_val in %s on line %d 804bool(true) 805array(0) { 806} 807 808Notice: Undefined variable: array_var in %s on line %d 809NULL 810bool(false) 811bool(false) 812bool(true) 813--- Outerloop Iteration 6 --- 814bool(false) 815bool(false) 816bool(false) 817bool(true) 818bool(false) 819bool(true) 820-- Innerloop Iteration 1 of Outerloop Iteration 6 -- 821array(3) { 822 [1]=> 823 int(2) 824 [2]=> 825 int(3) 826 [3]=> 827 int(4) 828} 829 830Notice: Undefined variable: key_val in %s on line %d 831bool(false) 832 833Notice: Undefined variable: key_val in %s on line %d 834bool(false) 835 836Notice: Undefined variable: key_val in %s on line %d 837bool(true) 838array(3) { 839 [1]=> 840 int(2) 841 [2]=> 842 int(3) 843 [3]=> 844 int(4) 845} 846-- Innerloop Iteration 2 of Outerloop Iteration 6 -- 847array(2) { 848 [2]=> 849 int(3) 850 [3]=> 851 int(4) 852} 853 854Notice: Undefined variable: key_val in %s on line %d 855bool(false) 856 857Notice: Undefined variable: key_val in %s on line %d 858bool(false) 859 860Notice: Undefined variable: key_val in %s on line %d 861bool(true) 862array(2) { 863 [2]=> 864 int(3) 865 [3]=> 866 int(4) 867} 868-- Innerloop Iteration 3 of Outerloop Iteration 6 -- 869array(1) { 870 [3]=> 871 int(4) 872} 873 874Notice: Undefined variable: key_val in %s on line %d 875bool(false) 876 877Notice: Undefined variable: key_val in %s on line %d 878bool(false) 879 880Notice: Undefined variable: key_val in %s on line %d 881bool(true) 882array(1) { 883 [3]=> 884 int(4) 885} 886-- Innerloop Iteration 4 of Outerloop Iteration 6 -- 887array(0) { 888} 889 890Notice: Undefined variable: key_val in %s on line %d 891bool(false) 892 893Notice: Undefined variable: key_val in %s on line %d 894bool(false) 895 896Notice: Undefined variable: key_val in %s on line %d 897bool(true) 898array(0) { 899} 900 901Notice: Undefined variable: array_var in %s on line %d 902NULL 903bool(false) 904bool(false) 905bool(true) 906--- Outerloop Iteration 7 --- 907bool(false) 908bool(false) 909bool(false) 910bool(true) 911bool(false) 912bool(true) 913-- Innerloop Iteration 1 of Outerloop Iteration 7 -- 914array(2) { 915 [1]=> 916 float(2.5) 917 [2]=> 918 float(5.6) 919} 920 921Notice: Undefined variable: key_val in %s on line %d 922bool(false) 923 924Notice: Undefined variable: key_val in %s on line %d 925bool(false) 926 927Notice: Undefined variable: key_val in %s on line %d 928bool(true) 929array(2) { 930 [1]=> 931 float(2.5) 932 [2]=> 933 float(5.6) 934} 935-- Innerloop Iteration 2 of Outerloop Iteration 7 -- 936array(1) { 937 [2]=> 938 float(5.6) 939} 940 941Notice: Undefined variable: key_val in %s on line %d 942bool(false) 943 944Notice: Undefined variable: key_val in %s on line %d 945bool(false) 946 947Notice: Undefined variable: key_val in %s on line %d 948bool(true) 949array(1) { 950 [2]=> 951 float(5.6) 952} 953-- Innerloop Iteration 3 of Outerloop Iteration 7 -- 954array(0) { 955} 956 957Notice: Undefined variable: key_val in %s on line %d 958bool(false) 959 960Notice: Undefined variable: key_val in %s on line %d 961bool(false) 962 963Notice: Undefined variable: key_val in %s on line %d 964bool(true) 965array(0) { 966} 967 968Notice: Undefined variable: array_var in %s on line %d 969NULL 970bool(false) 971bool(false) 972bool(true) 973--- Outerloop Iteration 8 --- 974bool(false) 975bool(false) 976bool(false) 977bool(true) 978bool(false) 979bool(true) 980-- Innerloop Iteration 1 of Outerloop Iteration 8 -- 981array(1) { 982 [2]=> 983 string(3) "two" 984} 985 986Notice: Undefined variable: key_val in %s on line %d 987bool(false) 988 989Notice: Undefined variable: key_val in %s on line %d 990bool(false) 991 992Notice: Undefined variable: key_val in %s on line %d 993bool(true) 994array(1) { 995 [2]=> 996 string(3) "two" 997} 998-- Innerloop Iteration 2 of Outerloop Iteration 8 -- 999array(0) { 1000} 1001 1002Notice: Undefined variable: key_val in %s on line %d 1003bool(false) 1004 1005Notice: Undefined variable: key_val in %s on line %d 1006bool(false) 1007 1008Notice: Undefined variable: key_val in %s on line %d 1009bool(true) 1010array(0) { 1011} 1012 1013Notice: Undefined variable: array_var in %s on line %d 1014NULL 1015bool(false) 1016bool(false) 1017bool(true) 1018--- Outerloop Iteration 9 --- 1019bool(false) 1020bool(false) 1021bool(false) 1022bool(true) 1023bool(false) 1024bool(true) 1025-- Innerloop Iteration 1 of Outerloop Iteration 9 -- 1026array(1) { 1027 ["Age"]=> 1028 string(2) "30" 1029} 1030 1031Notice: Undefined variable: key_val in %s on line %d 1032bool(false) 1033 1034Notice: Undefined variable: key_val in %s on line %d 1035bool(false) 1036 1037Notice: Undefined variable: key_val in %s on line %d 1038bool(true) 1039array(1) { 1040 ["Age"]=> 1041 string(2) "30" 1042} 1043-- Innerloop Iteration 2 of Outerloop Iteration 9 -- 1044array(0) { 1045} 1046 1047Notice: Undefined variable: key_val in %s on line %d 1048bool(false) 1049 1050Notice: Undefined variable: key_val in %s on line %d 1051bool(false) 1052 1053Notice: Undefined variable: key_val in %s on line %d 1054bool(true) 1055array(0) { 1056} 1057 1058Notice: Undefined variable: array_var in %s on line %d 1059NULL 1060bool(false) 1061bool(false) 1062bool(true) 1063--- Outerloop Iteration 10 --- 1064bool(false) 1065bool(false) 1066bool(false) 1067bool(true) 1068bool(false) 1069bool(true) 1070-- Innerloop Iteration 1 of Outerloop Iteration 10 -- 1071array(4) { 1072 [1]=> 1073 int(2) 1074 ["One"]=> 1075 string(1) "1" 1076 [2]=> 1077 string(3) "two" 1078 [""]=> 1079 string(0) "" 1080} 1081 1082Notice: Undefined variable: key_val in %s on line %d 1083bool(true) 1084 1085Notice: Undefined variable: key_val in %s on line %d 1086bool(true) 1087 1088Notice: Undefined variable: key_val in %s on line %d 1089bool(true) 1090array(4) { 1091 [1]=> 1092 int(2) 1093 ["One"]=> 1094 string(1) "1" 1095 [2]=> 1096 string(3) "two" 1097 [""]=> 1098 string(0) "" 1099} 1100-- Innerloop Iteration 2 of Outerloop Iteration 10 -- 1101array(3) { 1102 ["One"]=> 1103 string(1) "1" 1104 [2]=> 1105 string(3) "two" 1106 [""]=> 1107 string(0) "" 1108} 1109 1110Notice: Undefined variable: key_val in %s on line %d 1111bool(true) 1112 1113Notice: Undefined variable: key_val in %s on line %d 1114bool(true) 1115 1116Notice: Undefined variable: key_val in %s on line %d 1117bool(true) 1118array(3) { 1119 ["One"]=> 1120 string(1) "1" 1121 [2]=> 1122 string(3) "two" 1123 [""]=> 1124 string(0) "" 1125} 1126-- Innerloop Iteration 3 of Outerloop Iteration 10 -- 1127array(2) { 1128 [2]=> 1129 string(3) "two" 1130 [""]=> 1131 string(0) "" 1132} 1133 1134Notice: Undefined variable: key_val in %s on line %d 1135bool(true) 1136 1137Notice: Undefined variable: key_val in %s on line %d 1138bool(true) 1139 1140Notice: Undefined variable: key_val in %s on line %d 1141bool(true) 1142array(2) { 1143 [2]=> 1144 string(3) "two" 1145 [""]=> 1146 string(0) "" 1147} 1148-- Innerloop Iteration 4 of Outerloop Iteration 10 -- 1149array(1) { 1150 [""]=> 1151 string(0) "" 1152} 1153 1154Notice: Undefined variable: key_val in %s on line %d 1155bool(true) 1156 1157Notice: Undefined variable: key_val in %s on line %d 1158bool(true) 1159 1160Notice: Undefined variable: key_val in %s on line %d 1161bool(true) 1162array(1) { 1163 [""]=> 1164 string(0) "" 1165} 1166-- Innerloop Iteration 5 of Outerloop Iteration 10 -- 1167array(0) { 1168} 1169 1170Notice: Undefined variable: key_val in %s on line %d 1171bool(false) 1172 1173Notice: Undefined variable: key_val in %s on line %d 1174bool(false) 1175 1176Notice: Undefined variable: key_val in %s on line %d 1177bool(true) 1178array(0) { 1179} 1180 1181Notice: Undefined variable: array_var in %s on line %d 1182NULL 1183bool(false) 1184bool(false) 1185bool(true) 1186 1187*** Testing unset(), emtpy() & isset() with resource variables *** 1188-- Iteration 1 -- 1189resource(%d) of type (stream) 1190bool(true) 1191bool(false) 1192bool(true) 1193resource(%d) of type (stream) 1194bool(false) 1195bool(true) 1196bool(false) 1197bool(false) 1198 1199Notice: Undefined variable: resource in %s on line %d 1200NULL 1201-- Iteration 2 -- 1202resource(%d) of type (stream) 1203bool(true) 1204bool(false) 1205bool(true) 1206resource(%d) of type (stream) 1207bool(false) 1208bool(true) 1209bool(false) 1210bool(false) 1211 1212Notice: Undefined variable: resource in %s on line %d 1213NULL 1214 1215Notice: Undefined variable: resources in %s on line %d 1216NULL 1217bool(false) 1218bool(true) 1219 1220*** Testing unset(), empty() & isset() with objects *** 1221object(Point)#%d (3) { 1222 ["x"]=> 1223 int(30) 1224 ["y"]=> 1225 int(40) 1226 ["lable"]=> 1227 NULL 1228} 1229bool(true) 1230bool(false) 1231 1232Notice: Undefined variable: lable in %s on line %d 1233bool(false) 1234 1235Notice: Undefined variable: lable in %s on line %d 1236bool(true) 1237 1238Notice: Undefined variable: lable in %s on line %d 1239bool(false) 1240 1241Notice: Undefined variable: lable in %s on line %d 1242bool(true) 1243object(Point)#%d (3) { 1244 ["x"]=> 1245 int(30) 1246 ["y"]=> 1247 int(40) 1248 ["lable"]=> 1249 string(6) "Point1" 1250} 1251object(Point)#%d (2) { 1252 ["y"]=> 1253 int(40) 1254 ["lable"]=> 1255 string(6) "Point1" 1256} 1257bool(false) 1258bool(true) 1259object(Point)#%d (0) { 1260} 1261bool(true) 1262bool(false) 1263bool(false) 1264bool(true) 1265 1266Notice: Undefined variable: point1 in %s on line %d 1267NULL 1268bool(false) 1269bool(true) 1270bool(false) 1271bool(true) 1272array(3) { 1273 [0]=> 1274 string(5) "Point" 1275 [1]=> 1276 string(8) "setLable" 1277 [2]=> 1278 string(9) "testPoint" 1279} 1280object(Point)#%d (3) { 1281 ["x"]=> 1282 int(5) 1283 ["y"]=> 1284 int(6) 1285 ["lable"]=> 1286 NULL 1287} 1288 1289*** Testing possible variation in operation for isset(), empty() & unset() *** 1290 1291** Testing unset() variation 1: unset on static variable inside a function ** 1292value of static_var before unset: 1 1293bool(true) 1294bool(false) 1295 1296Notice: Undefined variable: static_var in %s on line %d 1297value of static_var after unset: 1298bool(false) 1299bool(true) 1300value of static_var after new assignment: 20 1301value of static_var before unset: 2 1302bool(true) 1303bool(false) 1304 1305Notice: Undefined variable: static_var in %s on line %d 1306value of static_var after unset: 1307bool(false) 1308bool(true) 1309value of static_var after new assignment: 20 1310value of static_var before unset: 3 1311bool(true) 1312bool(false) 1313 1314Notice: Undefined variable: static_var in %s on line %d 1315value of static_var after unset: 1316bool(false) 1317bool(true) 1318value of static_var after new assignment: 20 1319 1320** Testing unset() variation 2: unset on a variable passed by ref. inside of a function ** 1321string(5) "value" 1322bool(false) 1323bool(true) 1324string(5) "value" 1325 1326** Testing unset() variation 3: unset on a global variable inside of a function ** 1327int(10) 1328bool(true) 1329bool(false) 1330bool(false) 1331bool(true) 1332int(10) 1333===DONE=== 1334