By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,822 Members | 1,424 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,822 IT Pros & Developers. It's quick & easy.

PHP4 Object handling vs PHP5

P: n/a
Help me here. I've become a bitconfused about how PHP4 deals with
objects after reading this description of PHP5:

"PHP's handling of objects has been completely rewritten, allowing for
better performance and more features. In previous versions of PHP,
objects were handled like primitive types (for instance integers and
strings). The drawback of this method was that semantically the whole
object was copied when a variable was assigned, or pass as a parameter
to a method. In the new approach, objects are referenced by handle,
and not by value (one can think of a handle as an object's
identifier)."

I have always assumed that PHP4 uses a copy-on-write approach, so that
when you pass an object to a function by value, PHP doesn't actually
create a new copy of that object.
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
With total disregard for any kind of safety measures
ch***********@hotmail.com (Chung Leong) leapt forth and uttered:
I have always assumed that PHP4 uses a copy-on-write approach,
so that when you pass an object to a function by value, PHP
doesn't actually create a new copy of that object.


In PHP4 all variables are passed by value unless you explicitly tell
it to pass by reference. So unless you use the & when passing an
object to a function/method PHP4 will create a copy.

--
There is no signature.....
Jul 17 '05 #2

P: n/a
Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote in message news:<Xn*************************@206.127.4.22>...
With total disregard for any kind of safety measures
ch***********@hotmail.com (Chung Leong) leapt forth and uttered:
I have always assumed that PHP4 uses a copy-on-write approach,
so that when you pass an object to a function by value, PHP
doesn't actually create a new copy of that object.


In PHP4 all variables are passed by value unless you explicitly tell
it to pass by reference. So unless you use the & when passing an
object to a function/method PHP4 will create a copy.


The question is, does it create a physical copy (using up extra
memory) or a virtual copy (a physical copy happens only if one of the
copies is modified)?
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.