note 103296 added to function.func-get-args
| From: | mulllhausen at osu1 dot php dot net | Date: | Wed, 06 Apr 2011 02:49:06 +0000 |
| Subject: | note 103296 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178542@lists.php.net to get a copy of this message | ||
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]
?>
----
Server IP: 69.147.83.197
Probable Submitter: 150.101.100.168
----
Manual Page -- http://www.php.net/manual/en/function.func-get-args.php
Edit -- https://master.php.net/note/edit/103296
Del: integrated -- https://master.php.net/note/delete/103296/integrated
Del: useless -- https://master.php.net/note/delete/103296/useless
Del: bad code -- https://master.php.net/note/delete/103296/bad+code
Del: spam -- https://master.php.net/note/delete/103296/spam
Del: non-english -- https://master.php.net/note/delete/103296/non-english
Del: in docs -- https://master.php.net/note/delete/103296/in+docs
Del: other reasons-- https://master.php.net/note/delete/103296
Reject -- https://master.php.net/note/reject/103296
Search -- https://master.php.net/manage/user-notes.php