Annotation of embedaddon/php/ext/standard/tests/array/compact_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test compact() function: ensure compact() doesn't pick up variables declared outside of current scope.
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : proto array compact(mixed var_names [, mixed ...])
! 6: * Description: Creates a hash containing variables and their values
! 7: * Source code: ext/standard/array.c
! 8: * Alias to functions:
! 9: */
! 10: echo "*** Testing compact() : usage variations - variables outside of current scope ***\n";
! 11:
! 12: $a = 'main.a';
! 13: $b = 'main.b';
! 14:
! 15: function f() {
! 16: $b = 'f.b';
! 17: $c = 'f.c';
! 18: var_dump(compact('a','b','c'));
! 19: var_dump(compact(array('a','b','c')));
! 20: }
! 21:
! 22: f();
! 23:
! 24: ?>
! 25: ==Done==
! 26: --EXPECTF--
! 27: *** Testing compact() : usage variations - variables outside of current scope ***
! 28: array(2) {
! 29: ["b"]=>
! 30: string(3) "f.b"
! 31: ["c"]=>
! 32: string(3) "f.c"
! 33: }
! 34: array(2) {
! 35: ["b"]=>
! 36: string(3) "f.b"
! 37: ["c"]=>
! 38: string(3) "f.c"
! 39: }
! 40: ==Done==
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>