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