diff options
Diffstat (limited to 'ext/standard/tests/array/compact_variation2.phpt')
| -rw-r--r-- | ext/standard/tests/array/compact_variation2.phpt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/standard/tests/array/compact_variation2.phpt b/ext/standard/tests/array/compact_variation2.phpt new file mode 100644 index 0000000000..66b6bdbf76 --- /dev/null +++ b/ext/standard/tests/array/compact_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test compact() function: ensure compact() doesn't pick up variables declared outside of current scope. +--FILE-- +<?php +/* Prototype : proto array compact(mixed var_names [, mixed ...]) +* Description: Creates a hash containing variables and their values +* Source code: ext/standard/array.c +* Alias to functions: +*/ +echo "*** Testing compact() : usage variations - variables outside of current scope ***\n"; + +$a = 'main.a'; +$b = 'main.b'; + +function f() { + $b = 'f.b'; + $c = 'f.c'; + var_dump(compact('a','b','c')); + var_dump(compact(array('a','b','c'))); +} + +f(); + +?> +==Done== +--EXPECTF-- +*** Testing compact() : usage variations - variables outside of current scope *** +array(2) { + [u"b"]=> + unicode(3) "f.b" + [u"c"]=> + unicode(3) "f.c" +} +array(2) { + [u"b"]=> + unicode(3) "f.b" + [u"c"]=> + unicode(3) "f.c" +} +==Done==
\ No newline at end of file |
