note 103296 deleted from function.func-get-args by peehaa

From: Date: Mon, 08 Apr 2019 06:12:21 +0000
Subject: note 103296 deleted from function.func-get-args by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210553@lists.php.net to get a copy of this message
Note Submitter: mulllhausen ---- i use this structure a lot for debugging. i always place the call to 'debugfunc' at the start of any function which i want to debug. the square brackets in the echod output are useful to see if there is accidental whitespace within string variables passed to anyfunc. if anyone can suggest a better way of passing the names of the arguments to debugfunc i would appreciate it. as it is works fine, but its not very universal... <?php anyfunc('val1','val2','val3'); function anyfunc($arg1, $arg2, $arg3) { debugfunc(__FUNCTION__, '$arg1, $arg2, $arg3', func_get_args()); /*do useful non-debugging stuff*/ } function debugfunc($name, $arg_names, $arg_vals) { echo "begin function [$name]. "; $arg_names_array = explode(',', $arg_names); foreach($arg_names_array as $k => $v) { $v = trim($v); echo "$v: [$arg_vals[$k]] "; } echo "\n"; } //output: //begin function [anyfunc]. $arg1: [val1] $arg2: [val2] $arg3: [val3] ?>

« previous php.notes (#210553) next »