Do member functions within a class incur any memory penalty when an object of that class is instantiated.
Feb 18th, 2008 19:34
dman, David Marley, Paul Kenneth Egell-Johnsen, http://www.ttnr.org
I just found the information:
(search for objects, it should be a section in there 2/3 down the page):
"Some of the advantages of PHP 4 reference counting are less significant
with objects, since objects always have their own copy made on a method
(function) call. However, the object's properties do use reference
counting. See also Function parameters and reference counting."
There is the answer. The unprecedented approach...
In the light of this information, I think I would be reluctant to use
PHP objects as anything more than data structures unless the
application was very trivial.
This seems to be the advice of the PHP community in general but it
would be helpful if the PHP developers themselves were more direct
about the caveats of using objects. I wonder how many application
developers are using classes extensively in their code without being
aware of the potential drawbacks.