看板 PHP 關於我們 聯絡資訊
恕刪 ※ 引述《purplesand (CircusMonkey)》之銘言: : ※ 引述《purplesand (CircusMonkey)》之銘言: : 對不起各位..... : 放錯程式碼 : 應該 : <?php : $var1= "John"; : $var2= &$var1; : $var2= "Mary"; : echo $var2; : echo $var1; : ?> : 結果同上...............Orz 這個結果是正確的,這就是References的特性 也因為如此,Reference和Pointer很不一樣 PHP手冊有言:http://tw.php.net/manual/en/language.references.whatdo.php What References Do Refercnces是作啥的 PHP references allow you to make two variables to refer to the same content. Meaning, when you do: PHP的references允許你將兩個變數連到相同的內容。意思是,如果你這樣做: <?php $a =& $b; ?> it means that $a and $b point to the same content. 那表示$a和$b是指向一個相同的內容。 Note: $a and $b are completely equal here, that's not $a is pointing to $b or vice versa, that's $a and $b pointing to the same place. 注意:$a和$b在這裡完全相等,並非$a指向$b或$b指向$a,而是$a和$b都指向同一處。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.199.119 ※ 編輯: ybite 來自: 140.112.199.119 (07/02 00:03)
purplesand :感謝大大 了解了!!!!! 07/02 08:12
liaosankai :共用(參照)同一區的記體區塊,這樣想就對了 07/02 10:03
ileadu :指向同一個記憶體空間就對了 07/02 11:09