Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF, 078274121, info0a ip, should prodicers of software_based services be held liable or not liable for economic injuries

Links

XODOX
Impressum

#1: A change in the handling of function arguments

Posted on 2008-01-20 23:16:50 by Csaba Gabor

Between Dec 16, 2005 and May 31, 2006 a significant change occurred in
one aspect of how php (version 5.1 on Win XP) arguments are handled.
Consider the following script which changed behaviour in that
timeframe:

<?php
// Will func2 show 3 or 4 args from the following call?
argTester("func2", "two", "three", "four");

function argTester() {
// does a call to its first argument
print "in argTester with " . func_num_args() . " args;";
print " arg1: " . func_get_arg(0) . "\n\n";
return call_user_func_array (
"".array_shift($argsRest=func_get_args()), $argsRest); }

function func2 ($arg0) {
// displays its arguments
$aArg = func_get_args();
print "In " . __FUNCTION__ . " with " . func_num_args();
print " args: " . implode("; ", $aArg); }
?>

Should func2 show 3 or 4 arguments based on the last line of
argTester?

What I would like to determine is why the change came about,
and whether it was intentional or an artifact due to something else.
Could anyone point me to the proper group or person, please.

Thanks,
Csaba Gabor from Vienna

Report this message

#2: Re: A change in the handling of function arguments

Posted on 2008-01-21 01:12:24 by petersprc

In E_ALL | E_STRICT mode, the warning is: PHP Strict Standards: Only
variables should be passed by reference

array_shift expects a variable, but the newer php considers the
argument being passed an anonymous value it seems...

You can fix this by doing $rest = func_get_args() before array_shift.

On Jan 20, 5:16 pm, Csaba Gabor <dans...@gmail.com> wrote:
> Between Dec 16, 2005 and May 31, 2006 a significant change occurred in
> one aspect of how php (version 5.1 on Win XP) arguments are handled.
> Consider the following script which changed behaviour in that
> timeframe:
>
> <?php
> // Will func2 show 3 or 4 args from the following call?
> argTester("func2", "two", "three", "four");
>
> function argTester() {
> // does a call to its first argument
> print "in argTester with " . func_num_args() . " args;";
> print " arg1: " . func_get_arg(0) . "\n\n";
> return call_user_func_array (
> "".array_shift($argsRest=func_get_args()), $argsRest); }
>
> function func2 ($arg0) {
> // displays its arguments
> $aArg = func_get_args();
> print "In " . __FUNCTION__ . " with " . func_num_args();
> print " args: " . implode("; ", $aArg); }
> ?>
>
> Should func2 show 3 or 4 arguments based on the last line of
> argTester?
>
> What I would like to determine is why the change came about,
> and whether it was intentional or an artifact due to something else.
> Could anyone point me to the proper group or person, please.
>
> Thanks,
> Csaba Gabor from Vienna

Report this message