note 51707 deleted from function.array-walk by nlopess
| From: | nlopess@php.net | Date: | Fri, 08 Apr 2005 16:25:12 +0000 |
| Subject: | note 51707 deleted from function.array-walk by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-87711@lists.php.net to get a copy of this message | ||
Note Submitter: PHP Novice
----
While Hayley's comments about pass-by-reference will work for now, this is a deprecated
feature. I've been working with array_walk in a class and inside the callback I want to alter a
member field of the object. What I've discovered is that the $this object present during the
invokation of the callback is a copy of the original object. This of course means that your
modifications will be lost when you return from the array_walk call. The only solutions I've
come up with for this is to use the runtime pass-by-reference mechanism to provide a reference to
the field I want to modify and get the deprecation warning or break the encapsulation of my class
by using a global. (YUCK!) Can a PHP guru show me what I've missed (if anything) regarding this
issue?