我知道這是一種noob問題,但有人可以向我解釋這個函數是怎麼回事?傳遞一個變量在php中的參數數量
// Prints "hello mutated world"
function mutator($args=null) {
$n=count($args);
while($i<$n) $args[$i++] = "mutated";
}
$a = "hello";
$b = "strange";
$c = "world";
mutator(array($a, &$b, $c));
echo "$a $b $c";
我想具體什麼是$ i和$ n的價值? $ args = null是什麼意思,它是如何適應while循環的?提前致謝。
您沒有傳遞可變數量的參數,而是傳遞一個數組。 – 2013-10-25 21:31:43
我明白了,但這並不能幫助我理解這裏發生了什麼。我注意到mutator數組中的變量$ b旁邊的&simple,但仍不明白爲什麼它傳遞了變異。 –
然後,看看這個頁面將有助於:http://php.net/manual/en/language.references.php – 2013-10-25 21:39:47