|  | Posted by Jerry Stuckle on 12/27/07 14:40 
Steve wrote:> "Michael Fesser" <netizen@gmx.de> wrote in message
 > news:0hlim3hgb5p7ifm2o13pjm6q4l0q5jhiim@4ax.com...
 >> .oO(Logos)
 >>
 >>> On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.de> wrote:
 >>>
 >>>> At least when working with objects. But nevertheless
 >>>>
 >>>> $foo = new Test();
 >>>> $a = $foo;
 >>>> $b = &$foo;
 >>>>
 >>>> are still different things, even in PHP 5. In some particular situations
 >>>> this might become an issue.
 >>> Oooo...errr...ummm...could someone explain how exactly those are
 >>> different when using PHP5, then, please?  If everything is done by
 >>> reference for objects, then to me $a and $b both look like pointers to
 >>> an object.
 >> Don't confuse pointers with references, they are entirely different
 >> things. PHP doesn't know pointers.
 >>
 >> And correctly spoken objects in PHP 5 are _not_ passed by reference (at
 >> least it's not what PHP calls a reference), even if it's still mentioned
 >> that way on many websites. But it's wrong.
 >>
 >> Internally objects are represented by a handle (a simple number), which
 >> is what is moved around when you assign objects to variables, copy them
 >> or pass them to a function. You're never working directly with the
 >> object itself, but with its handle. Of course usually you won't notice
 >> that, because it's handled transparently by PHP.
 >
 > michael, for people who come from a c/c++ background, what you've described
 > is *exactly* a pointer. the only difference in php is that rather than the
 > handle pointing to a memory address where information is stored, this php
 > handle points to a symbol table entry where information is stored.
 >
 
 Wrong again, Stevie.  A C++ pointer is not the same as a C++ reference.
 And C doesn't have references, just as PHP doesn't have pointers.
 
 > in php, a reference (or byref) behaves *IDENTICALLY* to a c/c++ pointer.
 > there are somethings that you cannot do with this reference in php that you
 > could in other languages, however, the nature of the beast is the same. i
 > know that a reference in php is really just an alias of the symbol table
 > entry, but really that just seems a matter of symantics to me. i don't care
 > where things are stored at such a low level when i'm writing in a scripting
 > language. i care about behaviors.
 >
 
 Wrong again.  They behave much differently.
 
 
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |