对传递给函数的所有参数应用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