對傳遞給函數的所有參數應用php函數(如trim())的好方法,同時保留它們以便進一步處理?假設我們要修剪傳遞給郵件功能的所有參數:將php函數應用於所有函數參數
function my_function($a, $b, $c = NULL, $d, $e = NULL, $f = NULL){
$a = trim($a);
$b = trim($b);
$c = trim($c);
$d = trim($d);
$e = trim($e);
$f = trim($f);
// !!! i'd like something other than n lines of trim()...
// do further functioning on original *now trimmed* arguments...
my_function($to,$subject,$body,$from,$cc,$bcc);
func_get_args()等數組類型功能是不理想的,因爲我們的修剪參數是採取進一步行動無法與最初定義。我們是否需要使用某種數組然後重新組合原始參數?
可能使用get_defined_vars() – 2013-03-14 07:40:35