note 24415 added to function.compact
| From: | marc dot webb at sinclair dot edu | Date: | Thu, 15 Aug 2002 16:35:05 +0000 |
| Subject: | note 24415 added to function.compact | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35075@lists.php.net to get a copy of this message | ||
If you ever want to get lazy when passing variables to functions, you might try this procedure which
dumps all defined variables into one array, passes the one array to a function and splits it back
into the original variables:
function my_function($all_vars)
{
extract($all_vars);
//meat of function
}
$all_vars=get_defined_vars();
my_function($all_vars);
This is a lot easier than passing 10 arguments and having to type them for the function definition
and all the function calls in your program.
This also helps if you generate variable numbers of arguments, haven't planned ahead for them,
and the beta code is due by 5:00.
--
http://www.php.net/manual/en/function.compact.php
http://master.php.net/manage/user-notes.php?action=edit+24415
http://master.php.net/manage/user-notes.php?action=delete+24415
http://master.php.net/manage/user-notes.php?action=reject+24415