PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > A change in the handling of function arguments
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
A change in the handling of function arguments

Réponse
 
LinkBack Outils de la discussion
Vieux 20/01/2008, 22h16   #1
Csaba Gabor
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut A change in the handling of function arguments

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
  Réponse avec citation
Vieux 21/01/2008, 00h12   #2
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A change in the handling of function arguments

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


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h35.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08676 seconds with 10 queries