On 7/14/2011 7:44 PM, Daevid Vincent wrote: > Ah! Thanks Simon! That is exactly right. Doh! I should have thought of > that... *smacks head* > > Here is the fruit of my labor (and your fix)... > > /** > * Useful for debugging functions to see parameter names, etc. > * Based upon http://www.php.net/manual/en/function.func-get-args.php#103296 > * > * function anyfunc($arg1, $arg2, $arg3) > * { > * debug_func(__FUNCTION__, '$arg1, $arg2, $arg3', func_get_args()); > * //do useful non-debugging stuff > * } > * > * @access public > * @return string > * @param string $function_name __FUNCTION__ of the root function as > passed into this function > * @param string $arg_names the ',,,' encapsulated parameter list of > the root function > * @param array $arg_vals the result of func_get_args() from the root > function passed into this function > * @param boolean $show_empty_params (FALSE) > * @author Daevid Vincent > * @date 2011-17-14 > * @see func_get_args(), func_get_arg(), func_num_args() > */ > function debug_func($function_name, $arg_names, $arg_vals, > $show_empty_params=FALSE) > { > $params = array(); > echo $function_name.'('; > $arg_names_array = explode(',', $arg_names); > //var_dump($arg_names, $arg_names_array, $arg_vals ); > foreach($arg_names_array as $k => $parameter_name) > { > $v = $arg_vals[$k]; > //echo "k = $parameter_name = $k and v = arg_vals[k] = $v<br>\n"; > switch(true) > { > case is_string($v): if ($show_empty_params) $v = "'".$v."'" > ; break; > case is_null($v): if ($show_empty_params) $v = '{NULL}'; > break; > case is_bool($v): $v = ($v) ? '{TRUE}' : '{FALSE}'; break; > case is_array($v): (count($v) < 10) ? $v = > '['.implode(',',$v).']' : $v = '[ARRAY]'; break; > case is_object($v): $v = '{CLASS::'.get_class($v).'}'; > break; > case is_numeric($v): break; > } > > if ($show_empty_params || $v) $params[$k] = trim($parameter_name).': > '.$v; > } > echo implode(', ',$params).")<br/>\n"; > } > > > Can you give an example of where this might be useful? Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php