Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18754
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: ArrayObject vs array |
| Date | 2021-07-26 12:16 +0200 |
| Message-ID | <im7gccFa1nlU1@mid.individual.net> (permalink) |
| References | (4 earlier) <sdgs5f$1suj$1@gioia.aioe.org> <sdhgno$tt9$1@jstuckle.eternal-september.org> <sdj9us$o4p$1@gioia.aioe.org> <im4qbnFnmluU1@mid.individual.net> <sdlqtr$i7a$1@gioia.aioe.org> |
alex:
> Il 25/07/21 11:48, J.O. Aho ha scritto:
>>
>> You can make objects to have links to other objects (reference),
>
> That is?
<?php
$a = new Object();
// $b is a new reference ("link") to the object in $a and not(!) a copy
$b = $a;
// Now we change something in the object
$b->setName('foobar');
// This will return the same name wich was just set using $b since
// $b is just another reference to the object originally assinged to $a
$a->getName();
?>
If you need a copy of an object, you need to use the "clone" keyword:
<?php
$a = new Object();
// This will create a copy of the object in $b
$b = clone $a;
?>
--
Arno Welzel
https://arnowelzel.de
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar
ArrayObject vs array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-07-23 11:16 +0200
Re: ArrayObject vs array Jerry Stuckle <jstucklex@attglobal.net> - 2021-07-23 13:39 -0400
Re: ArrayObject vs array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-07-24 08:26 +0200
Re: ArrayObject vs array "J.O. Aho" <user@example.net> - 2021-07-24 12:10 +0200
Re: ArrayObject vs array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-07-24 13:05 +0200
Re: ArrayObject vs array Jerry Stuckle <jstucklex@attglobal.net> - 2021-07-24 12:56 -0400
Re: ArrayObject vs array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-07-25 11:13 +0200
Re: ArrayObject vs array "J.O. Aho" <user@example.net> - 2021-07-25 11:48 +0200
Re: ArrayObject vs array alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-07-26 10:14 +0200
Re: ArrayObject vs array "J.O. Aho" <user@example.net> - 2021-07-26 11:11 +0200
Re: ArrayObject vs array Arno Welzel <usenet@arnowelzel.de> - 2021-07-26 12:16 +0200
csiph-web