Re: [請益] 參照指派assign by reference
恕刪
※ 引述《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)
推
07/02 08:12, , 1F
07/02 08:12, 1F
推
07/02 10:03, , 2F
07/02 10:03, 2F
推
07/02 11:09, , 3F
07/02 11:09, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章