PHP4 Object handling vs PHP5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chung Leong

    PHP4 Object handling vs PHP5

    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.
  • Phil Roberts

    #2
    Re: PHP4 Object handling vs PHP5

    With total disregard for any kind of safety measures
    chernyshevsky@h otmail.com (Chung Leong) leapt forth and uttered:
    [color=blue]
    > 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.
    >[/color]

    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.....

    Comment

    • Chung Leong

      #3
      Re: PHP4 Object handling vs PHP5

      Phil Roberts <philrob@HOLYfl atnetSHIT.net> wrote in message news:<Xns942F72 61E9772philrobe rts@206.127.4.2 2>...[color=blue]
      > With total disregard for any kind of safety measures
      > chernyshevsky@h otmail.com (Chung Leong) leapt forth and uttered:
      >[color=green]
      > > 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.
      > >[/color]
      >
      > 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.[/color]

      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)?

      Comment

      Working...