diff options
author | Ant Phillips <ant@php.net> | 2008-12-02 13:32:53 +0000 |
---|---|---|
committer | Ant Phillips <ant@php.net> | 2008-12-02 13:32:53 +0000 |
commit | 2b1a411806c7b0e5692d5472e4f1da4b002b330e (patch) | |
tree | 1ca6b2cdf51cf89b552049a034f201cc48299083 /ext/standard/tests/array/compact_variation2.phpt | |
parent | ec1ee12281edfe6bcd148ade3711fbf3996e3738 (diff) | |
download | php-git-2b1a411806c7b0e5692d5472e4f1da4b002b330e.tar.gz |
Array tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit).
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..79db8ab047 --- /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) { + ["b"]=> + string(3) "f.b" + ["c"]=> + string(3) "f.c" +} +array(2) { + ["b"]=> + string(3) "f.b" + ["c"]=> + string(3) "f.c" +} +==Done==
\ No newline at end of file |