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 *** 28 29Notice: compact(): Undefined variable: a in %s on line %d 30array(2) { 31 ["b"]=> 32 string(3) "f.b" 33 ["c"]=> 34 string(3) "f.c" 35} 36 37Notice: compact(): Undefined variable: a in %s on line %d 38array(2) { 39 ["b"]=> 40 string(3) "f.b" 41 ["c"]=> 42 string(3) "f.c" 43} 44==Done== 45