note 129160 added to language.oop5.basic
| From: | gazianis2200 at gmail dot com | Date: | Sun, 14 Jan 2024 05:24:02 +0000 |
| Subject: | note 129160 added to language.oop5.basic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221114@lists.php.net to get a copy of this message | ||
<?php
$a = 10;
$b = $a;
$c =& $a;
$a = 20;
var_dump($a);//20
var_dump($b);//10
var_dump($c);//20
//if you modify the value of a class member then assign or reference to other variable are affected
to each other.
class Foo{
public $foo = 20;
}
$a = new Foo;
$b = $a;
$c =& $a;
$a = null;
var_dump($a);//NULL
var_dump($b);//object(Foo)#1 (1){["foo"]=>int(20)}
var_dump($c);//NULL
class Bar{
public $bar = 10;
}
$a = new Bar;
$b = $a;
$c =& $a;
$a->bar = 20;
var_dump($a->bar);//20
var_dump($b->bar);//20
var_dump($c->bar);//20
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 103.120.33.26)
----
Manual Page -- https://php.net/manual/en/language.oop5.basic.php
Edit -- https://main.php.net/note/edit/129160
Del: integrated -- https://main.php.net/note/delete/129160/integrated
Del: useless -- https://main.php.net/note/delete/129160/useless
Del: bad code -- https://main.php.net/note/delete/129160/bad+code
Del: spam -- https://main.php.net/note/delete/129160/spam
Del: non-english -- https://main.php.net/note/delete/129160/non-english
Del: in docs -- https://main.php.net/note/delete/129160/in+docs
Del: other reasons-- https://main.php.net/note/delete/129160
Reject -- https://main.php.net/note/reject/129160
Search -- https://main.php.net/manage/user-notes.php