PHPverse 2025

Voting

The Note You're Voting On

ario [a] mail [dot] utexas [dot] edu
18 years ago
"Because this function depends on the current scope to determine parameter details, it cannot be used as a function parameter. If you must pass this value, assign the results to a variable, and pass the variable."

This means that the following code generates an error:

<?php

function foo($list)
{
echo
implode(', ', $list);
}

function
foo2()
{
foo(func_get_args());
}

foo2(1, 2, 3);

?>

However, you can easily get around this by doing the following:

<?php

function foo($list)
{
echo
implode(', ', $list);
}

function
foo2()
{
foo($args = func_get_args());
}

foo2(1, 2, 3);

?>

This captures the context from foo2(), making this legal. You get the expected output:

"1, 2, 3"

<< Back to user notes page

To Top