Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18754
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: ArrayObject vs array |
| Date | Mon, 26 Jul 2021 12:16:44 +0200 |
| Lines | 39 |
| Message-ID | <im7gccFa1nlU1@mid.individual.net> (permalink) |
| References | <sde1e5$p89$1@gioia.aioe.org> <sdeuru$3h5$1@jstuckle.eternal-september.org> <sdgbps$18kp$1@gioia.aioe.org> <im277qF7fbjU1@mid.individual.net> <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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net OWeWuzkCfN4J1Vv85l5lawQ72qIMfi8SjFeDXYJGnBNPkn+/Hp |
| Cancel-Lock | sha1:CxpkXAPCAjCYlmh8ErYb94zk8rc= |
| In-Reply-To | <sdlqtr$i7a$1@gioia.aioe.org> |
| Xref | csiph.com comp.lang.php:18754 |
Show key headers only | View raw
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