RE: [PHP] Re: gloabl & reference behavior question?
| From: | Ford, Mike | Date: | Tue, 26 Jul 2005 11:02:26 +0000 |
| Subject: | RE: [PHP] Re: gloabl & reference behavior question? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-219336@lists.php.net to get a copy of this message | ||
On 22 July 2005 19:47, Surendra Singhi wrote:
> I don't think it will make the code confusing, but the person looking
> at the code should understand how reference and global variables
> work. Using reference variables avoids unnecessary extra copying of
> objects, and while
> using large arrays it can make a big difference in speed.
You shouldn't need to worry about this -- PHP tries to take care of it for
you. When you copy an array value, PHP only does a "shallow" copy (of the
array's address); if you later modify the array, this triggers a full "deep"
copy of all the array's element values before the modification is done.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm