note 49389 added to functions.arguments

From: Date: Wed, 26 Jan 2005 12:58:11 +0000
Subject: note 49389 added to functions.arguments
Groups: php.notes 
Request: Send a blank email to php-notes+get-84024@lists.php.net to get a copy of this message
Argument evaluation left to right means that you can save yourself a temporary variable in the example below whereas $current = $prior + ($prior=$current) is just the same as $current *= 2; function Sum() { return array_sum(func_get_args()); } function Fib($n,$current=1,$prior=0) { for (;--$n;) $current = Sum($prior,$prior=$current); return $current; } Csaba Gabor PS. You could, of course, just use array_sum(array(...)) in place of Sum(...) ---- Manual Page -- http://www.php.net/manual/en/functions.arguments.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49389 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49389&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49389&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49389&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49389&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49389&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49389&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84024) next »