note 18350 added to function.func-get-args
| From: | fbeyer at clickhand dot de dot noSpamPlease | Date: | Sat, 19 Jan 2002 13:02:51 +0000 |
| Subject: | note 18350 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25155@lists.php.net to get a copy of this message | ||
Another way of passing references with a dynamic number of arguments: (This example is limited to 10
arguments)
<?php
define('NULL_ARG', 'DUMMY_ARGUMENT');
function refArg($arg0 = NULL_ARG,
$arg1 = NULL_ARG,
$arg2 = NULL_ARG,
$arg3 = NULL_ARG,
$arg4 = NULL_ARG,
$arg5 = NULL_ARG,
$arg6 = NULL_ARG,
$arg7 = NULL_ARG,
$arg8 = NULL_ARG,
$arg9 = NULL_ARG)
{
for ($args=array(), $i=0; $i < 10; $i++) {
$name = 'arg' . $i;
if ($i < func_num_args()) {
$args[$i] = &$$name;
}
unset($$name, $name);
}
$args[0] = 'Modified.';
}
$test = 'Not modified.<br>';
refArg(&$test);
echo $test; // Prints 'Modified'
?>
--
http://www.php.net/manual/en/function.func-get-args.php
http://master.php.net/manage/user-notes.php?action=edit+18350
http://master.php.net/manage/user-notes.php?action=delete+18350
http://master.php.net/manage/user-notes.php?action=reject+18350