Annotation of embedaddon/php/Zend/tests/019.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
15: echo "*** 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;
50: foreach ($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:
81: echo "\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;
96: foreach ($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:
152: echo "\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;
160: foreach ($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
192: unset($resources);
193: var_dump($resources);
194: var_dump( isset($resources) ); //expected: bool(false)
195: var_dump( empty($resources) ); // expected: bool(true)
196:
197: echo "\n*** Testing unset(), empty() & isset() with objects ***\n";
198: class 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
219: var_dump($point1); // dump the object
220:
221: // check the object and member that is not set
222: var_dump( isset($point1) ); // expected: bool(true)
223: var_dump( empty($point1) ); // expected: bool(false)
224: var_dump( isset($point1->$lable) ); //expected: bool(flase)
225: var_dump( empty($point1->$lable) ); //expected: bool(true)
226:
227: //set the member variable lable and check
228: $point1->setLable("Point1");
229: var_dump( isset($point1->$lable) ); //expected: bool(true)
230: var_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
234: var_dump($point1);
235:
236: //unset a member and check
237: unset($point1->x);
238: // dump the point to see that variable was unset
239: var_dump($point1);
240: var_dump( isset($point1->x) ); // expected: bool(false)
241: var_dump( empty($point1->x) ); // expected: bool(true)
242:
243: // unset all members and check
244: unset($point1->y);
245: unset($point1->lable);
246: // dump the objec to check that all variables are unset
247: var_dump($point1);
248: var_dump( isset($point1) ); // expected: bool(ture)
249: var_dump( empty($point1) ); // expected: bool(false)
250:
251: //unset the object and check
252: unset($point1);
253: var_dump( isset($point1) ); // expected: bool(false)
254: var_dump( empty($point1) ); // expected: bool(true)
255: // dump to see that object is unset
256: var_dump($point1);
257:
258: // try isset/unset/empty on a member function
259: $point2 = new Point(5,6);
260: var_dump( isset($point2->testPoint) );
261: var_dump( empty($point2->testPoint) );
262: unset($point2->testPoint);
263: var_dump( isset($point2->testPoint) );
264: var_dump( empty($point2->testPoint) );
265:
266: // use get_class_methods to see effect if any
267: var_dump( get_class_methods($point2) );
268: // dump the object to see the effect, none expected
269: var_dump($point2);
270:
271: /* testing variation in operation for isset(), empty() & unset().
272: Note: 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:
276: echo "\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: */
281: echo "\n** Testing unset() variation 1: unset on static variable inside a function **\n";
282: function 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
305: test_unset1();
306: test_unset1();
307: test_unset1();
308:
309:
310: echo "\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: */
316: function 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";
328: var_dump($value);
329: test_unset2($value);
330: var_dump($value);
331:
332:
333: echo "\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:
341: function 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:
356: var_dump($global_var);
357: test_unset3();
358: var_dump($global_var);
359:
360: //Note: No error conditions relating to passing arugments 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 --
367: bool(true)
368: bool(true)
369: bool(true)
370:
371: Notice: Undefined variable: scalar_var in %s on line %d
372: NULL
373: bool(false)
374: bool(false)
375: bool(true)
376: bool(false)
377: bool(false)
378: -- Iteration 2 --
379: bool(true)
380: bool(true)
381: bool(false)
382:
383: Notice: Undefined variable: scalar_var in %s on line %d
384: NULL
385: bool(false)
386: bool(false)
387: bool(true)
388: bool(false)
389: bool(false)
390: -- Iteration 3 --
391: bool(true)
392: bool(true)
393: bool(true)
394:
395: Notice: Undefined variable: scalar_var in %s on line %d
396: NULL
397: bool(false)
398: bool(false)
399: bool(true)
400: bool(false)
401: bool(false)
402: -- Iteration 4 --
403: bool(true)
404: bool(true)
405: bool(false)
406:
407: Notice: Undefined variable: scalar_var in %s on line %d
408: NULL
409: bool(false)
410: bool(false)
411: bool(true)
412: bool(false)
413: bool(false)
414: -- Iteration 5 --
415: bool(true)
416: bool(true)
417: bool(false)
418:
419: Notice: Undefined variable: scalar_var in %s on line %d
420: NULL
421: bool(false)
422: bool(false)
423: bool(true)
424: bool(false)
425: bool(false)
426: -- Iteration 6 --
427: bool(true)
428: bool(true)
429: bool(false)
430:
431: Notice: Undefined variable: scalar_var in %s on line %d
432: NULL
433: bool(false)
434: bool(false)
435: bool(true)
436: bool(false)
437: bool(false)
438: -- Iteration 7 --
439: bool(true)
440: bool(true)
441: bool(false)
442:
443: Notice: Undefined variable: scalar_var in %s on line %d
444: NULL
445: bool(false)
446: bool(false)
447: bool(true)
448: bool(false)
449: bool(false)
450: -- Iteration 8 --
451: bool(true)
452: bool(true)
453: bool(true)
454:
455: Notice: Undefined variable: scalar_var in %s on line %d
456: NULL
457: bool(false)
458: bool(false)
459: bool(true)
460: bool(false)
461: bool(false)
462: -- Iteration 9 --
463: bool(true)
464: bool(true)
465: bool(false)
466:
467: Notice: Undefined variable: scalar_var in %s on line %d
468: NULL
469: bool(false)
470: bool(false)
471: bool(true)
472: bool(false)
473: bool(false)
474: -- Iteration 10 --
475: bool(true)
476: bool(true)
477: bool(false)
478:
479: Notice: Undefined variable: scalar_var in %s on line %d
480: NULL
481: bool(false)
482: bool(false)
483: bool(true)
484: bool(false)
485: bool(false)
486: -- Iteration 11 --
487: bool(true)
488: bool(true)
489: bool(false)
490:
491: Notice: Undefined variable: scalar_var in %s on line %d
492: NULL
493: bool(false)
494: bool(false)
495: bool(true)
496: bool(false)
497: bool(false)
498: -- Iteration 12 --
499: bool(true)
500: bool(true)
501: bool(false)
502:
503: Notice: Undefined variable: scalar_var in %s on line %d
504: NULL
505: bool(false)
506: bool(false)
507: bool(true)
508: bool(false)
509: bool(false)
510: -- Iteration 13 --
511: bool(true)
512: bool(true)
513: bool(true)
514:
515: Notice: Undefined variable: scalar_var in %s on line %d
516: NULL
517: bool(false)
518: bool(false)
519: bool(true)
520: bool(false)
521: bool(false)
522: -- Iteration 14 --
523: bool(true)
524: bool(true)
525: bool(true)
526:
527: Notice: Undefined variable: scalar_var in %s on line %d
528: NULL
529: bool(false)
530: bool(false)
531: bool(true)
532: bool(false)
533: bool(false)
534: -- Iteration 15 --
535: bool(true)
536: bool(true)
537: bool(false)
538:
539: Notice: Undefined variable: scalar_var in %s on line %d
540: NULL
541: bool(false)
542: bool(false)
543: bool(true)
544: bool(false)
545: bool(false)
546: -- Iteration 16 --
547: bool(true)
548: bool(true)
549: bool(false)
550:
551: Notice: Undefined variable: scalar_var in %s on line %d
552: NULL
553: bool(false)
554: bool(false)
555: bool(true)
556: bool(false)
557: bool(false)
558: -- Iteration 17 --
559: bool(true)
560: bool(true)
561: bool(false)
562:
563: Notice: Undefined variable: scalar_var in %s on line %d
564: NULL
565: bool(false)
566: bool(false)
567: bool(true)
568: bool(false)
569: bool(false)
570: -- Iteration 18 --
571: bool(true)
572: bool(true)
573: bool(false)
574:
575: Notice: Undefined variable: scalar_var in %s on line %d
576: NULL
577: bool(false)
578: bool(false)
579: bool(true)
580: bool(false)
581: bool(false)
582: -- Iteration 19 --
583: bool(true)
584: bool(true)
585: bool(true)
586:
587: Notice: Undefined variable: scalar_var in %s on line %d
588: NULL
589: bool(false)
590: bool(false)
591: bool(true)
592: bool(false)
593: bool(false)
594: -- Iteration 20 --
595: bool(true)
596: bool(true)
597: bool(false)
598:
599: Notice: Undefined variable: scalar_var in %s on line %d
600: NULL
601: bool(false)
602: bool(false)
603: bool(true)
604: bool(false)
605: bool(false)
606: -- Iteration 21 --
607: bool(true)
608: bool(true)
609: bool(false)
610:
611: Notice: Undefined variable: scalar_var in %s on line %d
612: NULL
613: bool(false)
614: bool(false)
615: bool(true)
616: bool(false)
617: bool(false)
618: -- Iteration 22 --
619: bool(true)
620: bool(true)
621: bool(false)
622:
623: Notice: Undefined variable: scalar_var in %s on line %d
624: NULL
625: bool(false)
626: bool(false)
627: bool(true)
628: bool(false)
629: bool(false)
630: -- Iteration 23 --
631: bool(true)
632: bool(true)
633: bool(false)
634:
635: Notice: Undefined variable: scalar_var in %s on line %d
636: NULL
637: bool(false)
638: bool(false)
639: bool(true)
640: bool(false)
641: bool(false)
642: -- Iteration 24 --
643: bool(true)
644: bool(true)
645: bool(false)
646:
647: Notice: Undefined variable: scalar_var in %s on line %d
648: NULL
649: bool(false)
650: bool(false)
651: bool(true)
652: bool(false)
653: bool(false)
654: -- Iteration 25 --
655: bool(true)
656: bool(true)
657: bool(true)
658:
659: Notice: Undefined variable: scalar_var in %s on line %d
660: NULL
661: bool(false)
662: bool(false)
663: bool(true)
664: bool(false)
665: bool(false)
666: -- Iteration 26 --
667: bool(true)
668: bool(true)
669: bool(false)
670:
671: Notice: Undefined variable: scalar_var in %s on line %d
672: NULL
673: bool(false)
674: bool(false)
675: bool(true)
676: bool(false)
677: bool(false)
678: -- Iteration 27 --
679: bool(true)
680: bool(true)
681: bool(true)
682:
683: Notice: Undefined variable: scalar_var in %s on line %d
684: NULL
685: bool(false)
686: bool(false)
687: bool(true)
688: bool(false)
689: bool(false)
690:
691: *** Testing unset(), empty() & isset() with arrays ***
692: --- Outerloop Iteration 1 ---
693: bool(false)
694: bool(false)
695: bool(false)
696: bool(true)
697: bool(true)
698: bool(true)
699:
700: Notice: Undefined variable: array_var in %s on line %d
701: NULL
702: bool(false)
703: bool(false)
704: bool(true)
705: --- Outerloop Iteration 2 ---
706: bool(false)
707: bool(false)
708: bool(false)
709: bool(true)
710: bool(false)
711: bool(true)
712: -- Innerloop Iteration 1 of Outerloop Iteration 2 --
713: array(0) {
714: }
715:
716: Notice: Undefined variable: key_val in %s on line %d
717: bool(false)
718:
719: Notice: Undefined variable: key_val in %s on line %d
720: bool(false)
721:
722: Notice: Undefined variable: key_val in %s on line %d
723: bool(true)
724: array(0) {
725: }
726:
727: Notice: Undefined variable: array_var in %s on line %d
728: NULL
729: bool(false)
730: bool(false)
731: bool(true)
732: --- Outerloop Iteration 3 ---
733: bool(false)
734: bool(false)
735: bool(false)
736: bool(true)
737: bool(false)
738: bool(true)
739: -- Innerloop Iteration 1 of Outerloop Iteration 3 --
740: array(0) {
741: }
742:
743: Notice: Undefined variable: key_val in %s on line %d
744: bool(false)
745:
746: Notice: Undefined variable: key_val in %s on line %d
747: bool(false)
748:
749: Notice: Undefined variable: key_val in %s on line %d
750: bool(true)
751: array(0) {
752: }
753:
754: Notice: Undefined variable: array_var in %s on line %d
755: NULL
756: bool(false)
757: bool(false)
758: bool(true)
759: --- Outerloop Iteration 4 ---
760: bool(false)
761: bool(false)
762: bool(false)
763: bool(true)
764: bool(false)
765: bool(true)
766: -- Innerloop Iteration 1 of Outerloop Iteration 4 --
767: array(0) {
768: }
769:
770: Notice: Undefined variable: key_val in %s on line %d
771: bool(false)
772:
773: Notice: Undefined variable: key_val in %s on line %d
774: bool(false)
775:
776: Notice: Undefined variable: key_val in %s on line %d
777: bool(true)
778: array(0) {
779: }
780:
781: Notice: Undefined variable: array_var in %s on line %d
782: NULL
783: bool(false)
784: bool(false)
785: bool(true)
786: --- Outerloop Iteration 5 ---
787: bool(false)
788: bool(false)
789: bool(false)
790: bool(true)
791: bool(false)
792: bool(true)
793: -- Innerloop Iteration 1 of Outerloop Iteration 5 --
794: array(0) {
795: }
796:
797: Notice: Undefined variable: key_val in %s on line %d
798: bool(false)
799:
800: Notice: Undefined variable: key_val in %s on line %d
801: bool(false)
802:
803: Notice: Undefined variable: key_val in %s on line %d
804: bool(true)
805: array(0) {
806: }
807:
808: Notice: Undefined variable: array_var in %s on line %d
809: NULL
810: bool(false)
811: bool(false)
812: bool(true)
813: --- Outerloop Iteration 6 ---
814: bool(false)
815: bool(false)
816: bool(false)
817: bool(true)
818: bool(false)
819: bool(true)
820: -- Innerloop Iteration 1 of Outerloop Iteration 6 --
821: array(3) {
822: [1]=>
823: int(2)
824: [2]=>
825: int(3)
826: [3]=>
827: int(4)
828: }
829:
830: Notice: Undefined variable: key_val in %s on line %d
831: bool(false)
832:
833: Notice: Undefined variable: key_val in %s on line %d
834: bool(false)
835:
836: Notice: Undefined variable: key_val in %s on line %d
837: bool(true)
838: array(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 --
847: array(2) {
848: [2]=>
849: int(3)
850: [3]=>
851: int(4)
852: }
853:
854: Notice: Undefined variable: key_val in %s on line %d
855: bool(false)
856:
857: Notice: Undefined variable: key_val in %s on line %d
858: bool(false)
859:
860: Notice: Undefined variable: key_val in %s on line %d
861: bool(true)
862: array(2) {
863: [2]=>
864: int(3)
865: [3]=>
866: int(4)
867: }
868: -- Innerloop Iteration 3 of Outerloop Iteration 6 --
869: array(1) {
870: [3]=>
871: int(4)
872: }
873:
874: Notice: Undefined variable: key_val in %s on line %d
875: bool(false)
876:
877: Notice: Undefined variable: key_val in %s on line %d
878: bool(false)
879:
880: Notice: Undefined variable: key_val in %s on line %d
881: bool(true)
882: array(1) {
883: [3]=>
884: int(4)
885: }
886: -- Innerloop Iteration 4 of Outerloop Iteration 6 --
887: array(0) {
888: }
889:
890: Notice: Undefined variable: key_val in %s on line %d
891: bool(false)
892:
893: Notice: Undefined variable: key_val in %s on line %d
894: bool(false)
895:
896: Notice: Undefined variable: key_val in %s on line %d
897: bool(true)
898: array(0) {
899: }
900:
901: Notice: Undefined variable: array_var in %s on line %d
902: NULL
903: bool(false)
904: bool(false)
905: bool(true)
906: --- Outerloop Iteration 7 ---
907: bool(false)
908: bool(false)
909: bool(false)
910: bool(true)
911: bool(false)
912: bool(true)
913: -- Innerloop Iteration 1 of Outerloop Iteration 7 --
914: array(2) {
915: [1]=>
916: float(2.5)
917: [2]=>
918: float(5.6)
919: }
920:
921: Notice: Undefined variable: key_val in %s on line %d
922: bool(false)
923:
924: Notice: Undefined variable: key_val in %s on line %d
925: bool(false)
926:
927: Notice: Undefined variable: key_val in %s on line %d
928: bool(true)
929: array(2) {
930: [1]=>
931: float(2.5)
932: [2]=>
933: float(5.6)
934: }
935: -- Innerloop Iteration 2 of Outerloop Iteration 7 --
936: array(1) {
937: [2]=>
938: float(5.6)
939: }
940:
941: Notice: Undefined variable: key_val in %s on line %d
942: bool(false)
943:
944: Notice: Undefined variable: key_val in %s on line %d
945: bool(false)
946:
947: Notice: Undefined variable: key_val in %s on line %d
948: bool(true)
949: array(1) {
950: [2]=>
951: float(5.6)
952: }
953: -- Innerloop Iteration 3 of Outerloop Iteration 7 --
954: array(0) {
955: }
956:
957: Notice: Undefined variable: key_val in %s on line %d
958: bool(false)
959:
960: Notice: Undefined variable: key_val in %s on line %d
961: bool(false)
962:
963: Notice: Undefined variable: key_val in %s on line %d
964: bool(true)
965: array(0) {
966: }
967:
968: Notice: Undefined variable: array_var in %s on line %d
969: NULL
970: bool(false)
971: bool(false)
972: bool(true)
973: --- Outerloop Iteration 8 ---
974: bool(false)
975: bool(false)
976: bool(false)
977: bool(true)
978: bool(false)
979: bool(true)
980: -- Innerloop Iteration 1 of Outerloop Iteration 8 --
981: array(1) {
982: [2]=>
983: string(3) "two"
984: }
985:
986: Notice: Undefined variable: key_val in %s on line %d
987: bool(false)
988:
989: Notice: Undefined variable: key_val in %s on line %d
990: bool(false)
991:
992: Notice: Undefined variable: key_val in %s on line %d
993: bool(true)
994: array(1) {
995: [2]=>
996: string(3) "two"
997: }
998: -- Innerloop Iteration 2 of Outerloop Iteration 8 --
999: array(0) {
1000: }
1001:
1002: Notice: Undefined variable: key_val in %s on line %d
1003: bool(false)
1004:
1005: Notice: Undefined variable: key_val in %s on line %d
1006: bool(false)
1007:
1008: Notice: Undefined variable: key_val in %s on line %d
1009: bool(true)
1010: array(0) {
1011: }
1012:
1013: Notice: Undefined variable: array_var in %s on line %d
1014: NULL
1015: bool(false)
1016: bool(false)
1017: bool(true)
1018: --- Outerloop Iteration 9 ---
1019: bool(false)
1020: bool(false)
1021: bool(false)
1022: bool(true)
1023: bool(false)
1024: bool(true)
1025: -- Innerloop Iteration 1 of Outerloop Iteration 9 --
1026: array(1) {
1027: ["Age"]=>
1028: string(2) "30"
1029: }
1030:
1031: Notice: Undefined variable: key_val in %s on line %d
1032: bool(false)
1033:
1034: Notice: Undefined variable: key_val in %s on line %d
1035: bool(false)
1036:
1037: Notice: Undefined variable: key_val in %s on line %d
1038: bool(true)
1039: array(1) {
1040: ["Age"]=>
1041: string(2) "30"
1042: }
1043: -- Innerloop Iteration 2 of Outerloop Iteration 9 --
1044: array(0) {
1045: }
1046:
1047: Notice: Undefined variable: key_val in %s on line %d
1048: bool(false)
1049:
1050: Notice: Undefined variable: key_val in %s on line %d
1051: bool(false)
1052:
1053: Notice: Undefined variable: key_val in %s on line %d
1054: bool(true)
1055: array(0) {
1056: }
1057:
1058: Notice: Undefined variable: array_var in %s on line %d
1059: NULL
1060: bool(false)
1061: bool(false)
1062: bool(true)
1063: --- Outerloop Iteration 10 ---
1064: bool(false)
1065: bool(false)
1066: bool(false)
1067: bool(true)
1068: bool(false)
1069: bool(true)
1070: -- Innerloop Iteration 1 of Outerloop Iteration 10 --
1071: array(4) {
1072: [1]=>
1073: int(2)
1074: ["One"]=>
1075: string(1) "1"
1076: [2]=>
1077: string(3) "two"
1078: [""]=>
1079: string(0) ""
1080: }
1081:
1082: Notice: Undefined variable: key_val in %s on line %d
1083: bool(true)
1084:
1085: Notice: Undefined variable: key_val in %s on line %d
1086: bool(true)
1087:
1088: Notice: Undefined variable: key_val in %s on line %d
1089: bool(true)
1090: array(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 --
1101: array(3) {
1102: ["One"]=>
1103: string(1) "1"
1104: [2]=>
1105: string(3) "two"
1106: [""]=>
1107: string(0) ""
1108: }
1109:
1110: Notice: Undefined variable: key_val in %s on line %d
1111: bool(true)
1112:
1113: Notice: Undefined variable: key_val in %s on line %d
1114: bool(true)
1115:
1116: Notice: Undefined variable: key_val in %s on line %d
1117: bool(true)
1118: array(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 --
1127: array(2) {
1128: [2]=>
1129: string(3) "two"
1130: [""]=>
1131: string(0) ""
1132: }
1133:
1134: Notice: Undefined variable: key_val in %s on line %d
1135: bool(true)
1136:
1137: Notice: Undefined variable: key_val in %s on line %d
1138: bool(true)
1139:
1140: Notice: Undefined variable: key_val in %s on line %d
1141: bool(true)
1142: array(2) {
1143: [2]=>
1144: string(3) "two"
1145: [""]=>
1146: string(0) ""
1147: }
1148: -- Innerloop Iteration 4 of Outerloop Iteration 10 --
1149: array(1) {
1150: [""]=>
1151: string(0) ""
1152: }
1153:
1154: Notice: Undefined variable: key_val in %s on line %d
1155: bool(true)
1156:
1157: Notice: Undefined variable: key_val in %s on line %d
1158: bool(true)
1159:
1160: Notice: Undefined variable: key_val in %s on line %d
1161: bool(true)
1162: array(1) {
1163: [""]=>
1164: string(0) ""
1165: }
1166: -- Innerloop Iteration 5 of Outerloop Iteration 10 --
1167: array(0) {
1168: }
1169:
1170: Notice: Undefined variable: key_val in %s on line %d
1171: bool(false)
1172:
1173: Notice: Undefined variable: key_val in %s on line %d
1174: bool(false)
1175:
1176: Notice: Undefined variable: key_val in %s on line %d
1177: bool(true)
1178: array(0) {
1179: }
1180:
1181: Notice: Undefined variable: array_var in %s on line %d
1182: NULL
1183: bool(false)
1184: bool(false)
1185: bool(true)
1186:
1187: *** Testing unset(), emtpy() & isset() with resource variables ***
1188: -- Iteration 1 --
1189: resource(%d) of type (stream)
1190: bool(true)
1191: bool(false)
1192: bool(true)
1193: resource(%d) of type (stream)
1194: bool(false)
1195: bool(true)
1196: bool(false)
1197: bool(false)
1198:
1199: Notice: Undefined variable: resource in %s on line %d
1200: NULL
1201: -- Iteration 2 --
1202: resource(%d) of type (stream)
1203: bool(true)
1204: bool(false)
1205: bool(true)
1206: resource(%d) of type (stream)
1207: bool(false)
1208: bool(true)
1209: bool(false)
1210: bool(false)
1211:
1212: Notice: Undefined variable: resource in %s on line %d
1213: NULL
1214:
1215: Notice: Undefined variable: resources in %s on line %d
1216: NULL
1217: bool(false)
1218: bool(true)
1219:
1220: *** Testing unset(), empty() & isset() with objects ***
1221: object(Point)#%d (3) {
1222: ["x"]=>
1223: int(30)
1224: ["y"]=>
1225: int(40)
1226: ["lable"]=>
1227: NULL
1228: }
1229: bool(true)
1230: bool(false)
1231:
1232: Notice: Undefined variable: lable in %s on line %d
1233: bool(false)
1234:
1235: Notice: Undefined variable: lable in %s on line %d
1236: bool(true)
1237:
1238: Notice: Undefined variable: lable in %s on line %d
1239: bool(false)
1240:
1241: Notice: Undefined variable: lable in %s on line %d
1242: bool(true)
1243: object(Point)#%d (3) {
1244: ["x"]=>
1245: int(30)
1246: ["y"]=>
1247: int(40)
1248: ["lable"]=>
1249: string(6) "Point1"
1250: }
1251: object(Point)#%d (2) {
1252: ["y"]=>
1253: int(40)
1254: ["lable"]=>
1255: string(6) "Point1"
1256: }
1257: bool(false)
1258: bool(true)
1259: object(Point)#%d (0) {
1260: }
1261: bool(true)
1262: bool(false)
1263: bool(false)
1264: bool(true)
1265:
1266: Notice: Undefined variable: point1 in %s on line %d
1267: NULL
1268: bool(false)
1269: bool(true)
1270: bool(false)
1271: bool(true)
1272: array(3) {
1273: [0]=>
1274: string(5) "Point"
1275: [1]=>
1276: string(8) "setLable"
1277: [2]=>
1278: string(9) "testPoint"
1279: }
1280: object(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 **
1292: value of static_var before unset: 1
1293: bool(true)
1294: bool(false)
1295:
1296: Notice: Undefined variable: static_var in %s on line %d
1297: value of static_var after unset:
1298: bool(false)
1299: bool(true)
1300: value of static_var after new assignment: 20
1301: value of static_var before unset: 2
1302: bool(true)
1303: bool(false)
1304:
1305: Notice: Undefined variable: static_var in %s on line %d
1306: value of static_var after unset:
1307: bool(false)
1308: bool(true)
1309: value of static_var after new assignment: 20
1310: value of static_var before unset: 3
1311: bool(true)
1312: bool(false)
1313:
1314: Notice: Undefined variable: static_var in %s on line %d
1315: value of static_var after unset:
1316: bool(false)
1317: bool(true)
1318: value of static_var after new assignment: 20
1319:
1320: ** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **
1321: string(5) "value"
1322: bool(false)
1323: bool(true)
1324: string(5) "value"
1325:
1326: ** Testing unset() variation 3: unset on a global variable inside of a function **
1327: int(10)
1328: bool(true)
1329: bool(false)
1330: bool(false)
1331: bool(true)
1332: int(10)
1333: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>