对象引用有关问题

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

对象引用问题

class A{
public $foo = 1;
}
$a = new A();
$b = $a;
$b->foo = 2;
echo $a->foo . "
";

$c = new A();
$d = & $c;
$d->foo = 3;
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!