update : 2015.11.03
php.shukuma.com검색:
|
References inside the constructorCreating references within the constructor can lead to confusing results. This tutorial-like section helps you to avoid problems.
<?php Let us check out if there is a difference between $bar1 which has been created using the copy = operator and $bar2 which has been created using the reference =& operator...
<?php Apparently there is no difference, but in fact there is a very significant one: $bar1 and $globalref[0] are _NOT_ referenced, they are NOT the same variable. This is because "new" does not return a reference by default, instead it returns a copy. To prove what is written above let us watch the code below.
<?php Another final example, try to understand it.
<?php 위 예제의 출력: class A: 10 class B: 10 class B: 10 class A: 11 class B: 11 class B: 11 |