1--TEST-- 2Test 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*/ 10echo "*** Testing compact() : usage variations - variables outside of current scope ***\n"; 11 12$a = 'main.a'; 13$b = 'main.b'; 14 15function 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 22f(); 23 24?> 25==Done== 26--EXPECTF-- 27*** Testing compact() : usage variations - variables outside of current scope *** 28array(2) { 29 ["b"]=> 30 string(3) "f.b" 31 ["c"]=> 32 string(3) "f.c" 33} 34array(2) { 35 ["b"]=> 36 string(3) "f.b" 37 ["c"]=> 38 string(3) "f.c" 39} 40==Done== 41