note 49389 deleted from functions.arguments by cmb

From: Date: Sun, 10 Nov 2019 12:58:49 +0000
Subject: note 49389 deleted from functions.arguments by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213019@lists.php.net to get a copy of this message
Note Submitter: csaba at alum dot mit dot edu ---- 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(...)

« previous php.notes (#213019) next »