class a
class b
function normalassignment($obj)
function referenceassignment(&$obj)
$a = new a;
$b = $a;
$b->foo = 'abc';//對$a的成員造成了影響
$b = new b;//不影響$a
echo $a->foo;//abc
normalassignment($a);
echo get_class($a), "\n";//a
echo "foo = \n";//foo = changed
referenceassignment($a);
echo get_class($a), "\n";//b
echo "foo = \n";//foo = empty
echo "bar = \n";//bar = hello
PHP手冊 引用返回,取消引用
引用返回class foo obj new foo myvalue obj getvalue myvalue is a reference to obj value,which is 42.obj value 2 echo myvalue prints the new value of obj va...
PHP 物件和引用
一直以為認為的 php5 物件預設是引用傳遞的 這個想法貌似是不對的。看下面的例子 class a class b public function bar a bar public function ref a bar f new a g new b echo f foo n 輸出1 g foo f...
php 頁面引用 php 檔案引用
引用檔案是將另乙個原始檔的全部內容包含到當前原始檔匯中進行使用,引用外部檔案可以減少 的重複編寫。php提供了include語句 require語句 include once語句及require once語句實現引用檔案。include include once include 語句將引用指定檔案中...