对象引用有关问题

WBOY
Release: 2016-06-13 12:03:52
Original
901 people have browsed it

对象引用问题

class A{<br />	public $foo = 1;<br />}<br />$a = new A();<br />$b = $a;<br />$b->foo = 2;<br />echo $a->foo . "<br />";<br /><br />$c = new A();<br />$d = & $c;<br />$d->foo = 3;<br />echo $c->foo;
Copy after login

$b=$a 和 $d=&$c 有什么区别啊,这里用不用 & 都没什么不同
------解决方案--------------------
= 传值
=& 传引用
对象总是以 引用 传递的
所以对于对象 = 和 =& 没有区别

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template