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

PHP5 and class inheritance question

P: n/a
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!

(code abbreviated for clarity)

I have a parent class, DetailCollection, with a child class
KeycodeTracker:

class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}
}

class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
echo(count("KeyTrk".$this->aODetails."<BR>"));
}
}

DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.

Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?

Thanks for taking a peek!
Tyler
Dec 11 '07 #1
Share this Question
Share on Google+
30 Replies


P: n/a

"Logos" <ty*********@gmail.comwrote in message
news:07**********************************@e6g2000p rf.googlegroups.com...
>I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!

(code abbreviated for clarity)

I have a parent class, DetailCollection, with a child class
KeycodeTracker:

class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}
}

class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
there's your problem. you need:

parent::setDetail($oDetail, true);

DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.
it may very well call setDetail on the 'original class', but not a specific
instance. you must be running php < 5, otherwise, you'd be seeing all kinds
of balking spewing from php into your browser. :^)

you need an *instance* of DataCollection. the correct instance would be the
one you're extending...parent.
Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?
no to the former, yes, the latter.

btw, php is not visual basic. visual basic is no longer visual basic. the
point? it is considered bad form to prefix variables with their data type
(vb has been the biggest purveyor). this is especially true in scripting
languages...where all variables are variants with little constrain on
changing them from one type to another. there are tons of articles that
cover why, i'll let you google that. i'll just mention it here and leave it
at that.
Dec 11 '07 #2

P: n/a
Greetings, Logos.
In reply to Your message dated Tuesday, December 11, 2007, 05:39:40,
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!
(code abbreviated for clarity)
I have a parent class, DetailCollection, with a child class
KeycodeTracker:
class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}
}
class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
echo(count("KeyTrk".$this->aODetails."<BR>"));
}
}
DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.
Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?
The variable private $aODetails; from class DetailCollection is not exists in
the class KeycodeTracker derived from it.
Even if You dealing with it, it is KeycodeTracker own private $aODetails;
variable.
If You want it to be inherited, declare it as protected.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Dec 12 '07 #3

P: n/a
On Dec 10, 10:27 pm, "Steve" <no....@example.comwrote:
there's your problem. you need:

parent::setDetail($oDetail, true);
Aha! Thank you. I knew it was some kind of mistake arising from my
unfamiliarity with PHP.
DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.

it may very well call setDetail on the 'original class', but not a specific
instance. you must be running php < 5, otherwise, you'd be seeing all kinds
of balking spewing from php into your browser. :^)

you need an *instance* of DataCollection. the correct instance would be the
one you're extending...parent.
Actually, I am running PHP5. Does not choke or die at all, nor do any
of my exception handlers catch anything. It just sets aODetails to
null.
btw, php is not visual basic. visual basic is no longer visual basic. the
point? it is considered bad form to prefix variables with their data type
(vb has been the biggest purveyor). this is especially true in scripting
languages...where all variables are variants with little constrain on
changing them from one type to another. there are tons of articles that
cover why, i'll let you google that. i'll just mention it here and leave it
at that.
I've never used VB, actually, tho did I use BASIC back in the Atari
400 days. I've mostly gotten by with C, C++ and Java. As for
prefixing variables with their type, whether or not it is bad form is
purely a stylistic issue of opinion. My preference is to put a
hungarian prefix on there to hint to me what I'm expecting. Usually I
don't need it, but when I do it's a huge timesaver, and people looking
at my code for the first time frequently find it handy. For example,
with cust ids - are they purely numeric? alphanumeric? Is that
function expecting a part object, or just the part id? The prefix
helps remind me. I do it in ECMA/Javascript as well. Seeing as it's
simply a naming convention, and the names of variables don't affect
how they're used or how they're processed, I think it's pretty much
moot whether it's used or not. Thanks for the advice, tho.
Dec 12 '07 #4

P: n/a
On Dec 12, 11:25 am, AnrDaemon <anrdae...@freemail.ruwrote:
Greetings, Logos.
In reply to Your message dated Tuesday, December 11, 2007, 05:39:40,
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!
(code abbreviated for clarity)
I have a parent class, DetailCollection, with a child class
KeycodeTracker:
class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}
}
class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
echo(count("KeyTrk".$this->aODetails."<BR>"));
}
}
DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.
Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?

The variable private $aODetails; from class DetailCollection is not exists in
the class KeycodeTracker derived from it.
Even if You dealing with it, it is KeycodeTracker own private $aODetails;
variable.
If You want it to be inherited, declare it as protected.

--
Sincerely Yours, AnrDaemon <anrdae...@freemail.ru>
Thank you! I was just coming back to post that correcting parent::
hadn't solved my problem. You are my hero! Mmm, scope
resolution...minty fresh flavour!
Dec 12 '07 #5

P: n/a
Greetings, Logos.
In reply to Your message dated Wednesday, December 12, 2007, 22:25:28,
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!
(code abbreviated for clarity)
I have a parent class, DetailCollection, with a child class
KeycodeTracker:
class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}
}
class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
echo(count("KeyTrk".$this->aODetails."<BR>"));
}
}
DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.
Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?

The variable private $aODetails; from class DetailCollection is not exists in
the class KeycodeTracker derived from it.
Even if You dealing with it, it is KeycodeTracker own private $aODetails;
variable.
If You want it to be inherited, declare it as protected.
Thank you! I was just coming back to post that correcting parent::
hadn't solved my problem. You are my hero! Mmm, scope
resolution...minty fresh flavour!
Do not salute me much... I've figured that when I was where You and stuck with
inappropriate results from code looking perfectly right... :-/
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Dec 12 '07 #6

P: n/a
On Dec 12, 1:12 pm, AnrDaemon <anrdae...@freemail.ruwrote:
Do not salute me much... I've figured that when I was where You and stuck with
inappropriate results from code looking perfectly right... :-/

--
Sincerely Yours, AnrDaemon <anrdae...@freemail.ru>
I shall salute you for being gracious enough to still read thru
obviously noob posts and try to help, then. Skaal!
Dec 13 '07 #7

P: n/a

"Logos" <ty*********@gmail.comwrote in message
news:30**********************************@i29g2000 prf.googlegroups.com...
On Dec 12, 1:21 pm, "Steve" <no....@example.comwrote:
Actually, it's still a stylistic issue, as naming conventions don't
affect type even in strongly typed language. <grin Anways, for me
the prefixes are there to hint, not to be a hard and fast definition
of the variable; I don't use strict hungarian notation at all. For
me, i=any number without a decimal, f=# with decimal, s=string,
c=char, o=object, a=array. That's it.

i know that...however, you 'hint' becomes very misleading when that happens
and even achieves the opposite under those cases.
Thanks for the advice, tho.

you can tell me to stick it, really. i'm too free with the advice
sometimes.

Twasn't meant as sarcasm, actually. I meant it sincerely. S'why it's
never a good idea to read too much into text. Maybe I should start
prefixing all my paragraphs with smilies, a la hungarian, to hint at
intent there too! <rofl>
i know it wasn't sarcasm. i appreciated it enough to say 'don't mind me too
much'.
>hope you got everything running well.

I did, and I am most pleased. Usenet remains my VERY good friend!
excellent.
Dec 13 '07 #8

P: n/a
On Dec 11, 3:39 am, Logos <tyler.st...@gmail.comwrote:
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!

(code abbreviated for clarity)

I have a parent class, DetailCollection, with a child class
KeycodeTracker:

class DetailCollection{
private $aODetails;
private function setDetail(&$oDetail, $bEcho=false) {
$this->aODetails[] =$oDetail;
if($bEcho) { echo(count("DetCol".$this->aODetails."<BR>")); }
}

}

class KeycodeTracker extends DetailCollection{
private function setDetail(&$oDetail) {
DetailCollection::setDetail($oDetail, true);
echo(count("KeyTrk".$this->aODetails."<BR>"));
}

}

DetailCollection has a method called setDetail, which takes an object
passed by reference and stashes it in an array. This works fine in
another child class that overrides DetailCollection's setDetail, but
KeycodeTracker uses a call to the original class and does not work -
there are no elements in $this->aODetails.

Does this have anything to do with overriding a pass by reference
method in some way? Or am I just a victim of my own newbieness here?

Thanks for taking a peek!
Tyler
hi there

in addition to what's already said, there's no need to use references
in php5.
--
gosha bine

[gui for google chart api http://www.tagarga.com/files/gcui]
[makrell http://www.tagarga.com/blok/makrell]
Dec 13 '07 #9

P: n/a
..oO(gosha bine)
>in addition to what's already said, there's no need to use references
in php5.
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.

Micha
Dec 13 '07 #10

P: n/a
On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
.oO(gosha bine)
in addition to what's already said, there's no need to use references
in php5.

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.

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

And...are objects always passed by reference to functions in PHP5,
then?
Dec 19 '07 #11

P: n/a

"Logos" <ty*********@gmail.comwrote in message
news:62**********************************@e25g2000 prg.googlegroups.com...
On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>.oO(gosha bine)
>in addition to what's already said, there's no need to use references
in php5.

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.

Micha

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.

And...are objects always passed by reference to functions in PHP5,
then?
alright, get ready for a ton of flamage here after i'm done...

first, to be correct and accurate...objects are passed to functions by
reference, objects in arrays are by reference (i.e. when using foreach),
etc., etc.. variable assignment is by value. while $b = &$foo behaves like a
pointer in *every* way, in php there are no true c-style pointers. $b is
just an alias for $foo, a nickname...because of the amphersand (&). make
sense?
Dec 19 '07 #12

P: n/a

"Steve" <no****@example.comwrote in message
news:qm*************@newsfe07.lga...
>
"Logos" <ty*********@gmail.comwrote in message
news:62**********************************@e25g2000 prg.googlegroups.com...
>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>.oO(gosha bine)

in addition to what's already said, there's no need to use references
in php5.

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.

Micha

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.

And...are objects always passed by reference to functions in PHP5,
then?

alright, get ready for a ton of flamage here after i'm done...

first, to be correct and accurate...objects are passed to functions by
reference, objects in arrays are by reference (i.e. when using foreach),
etc., etc.. variable assignment is by value. while $b = &$foo behaves like
a pointer in *every* way, in php there are no true c-style pointers. $b is
just an alias for $foo, a nickname...because of the amphersand (&). make
sense?
here's a link for you to read having much discussion about referencing. in
particular, i have used some of the hacks shown there and have made a few of
my own based on the descriptions of how php is handling referencing in
different situation.

hth.

http://us.php.net/language.references.pass
Dec 19 '07 #13

P: n/a
..oO(Logos)
>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>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.

New Object Model
http://www.php.net/manual/en/migration5.oop.php

| [Objects in PHP 4] The drawback of this method was that semantically
| the whole object was copied when a variable was assigned, or passed 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).

Of course in addition to these object handles there are still the normal
PHP references, which you can use as well. So in the example code above
$a contains a copy of the object handle which was created beforehand,
while $b is a reference to that handle. That's a difference.

Here's a background article regarding this issue (and some more):

You're being lied to.
http://blog.libssh2.org/index.php?/a...-lied-to..html

Micha
Dec 19 '07 #14

P: n/a

"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com...
.oO(Logos)
>>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>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.

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.
New Object Model
http://www.php.net/manual/en/migration5.oop.php

| [Objects in PHP 4] The drawback of this method was that semantically
| the whole object was copied when a variable was assigned, or passed 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).
to be accurate, the handle needn't be a number.
Of course in addition to these object handles there are still the normal
PHP references, which you can use as well.
please explain, as there are no 'special' references in php. you seem to be
comparing a reference directly with a thing that makes references work.
So in the example code above
$a contains a copy of the object handle which was created beforehand,
while $b is a reference to that handle. That's a difference.
no, this is wholly wrong.

new object() creates an entry in the symbol table. that entry has a handle.
$foo becomes an alias for that handle. $a gets a new handle in the symbol
table whereby the entry data is copied into it from $foo. $b is an alias of
$foo.

$a is NOT a copy of the $foo's object handle - that would be an *alias*...a
*reference*. $foo's symbol data is copied into a new entry and $a gets the
handle for that entry. it's an important distinction.
Here's a background article regarding this issue (and some more):

You're being lied to.
http://blog.libssh2.org/index.php?/a...-lied-to..html
by whom, micha?
Dec 19 '07 #15

P: n/a
..oO(Steve)
>"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com.. .
>>
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.
A handle is not 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.
Exactly. A pointer contains a memory address, a handle doesn't.
>in php, a reference (or byref) behaves *IDENTICALLY* to a c/c++ pointer.
Nope. References in PHP behave like references in C++, they're just
alias names for the same data structure. That's a big difference to
pointers, which don't exist in PHP. For example the memory address a
pointer points to could be another pointer as well. Such things are not
possible with references, neither in C++ nor in PHP. If you assign a
reference to a reference, it'll just become an additional alias.
>New Object Model
http://www.php.net/manual/en/migration5.oop.php

| [Objects in PHP 4] The drawback of this method was that semantically
| the whole object was copied when a variable was assigned, or passed 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).

to be accurate, the handle needn't be a number.
Correct, but it probably makes it easier and more efficient.
>Of course in addition to these object handles there are still the normal
PHP references, which you can use as well.

please explain, as there are no 'special' references in php. you seem to be
comparing a reference directly with a thing that makes references work.
The combination handle->object is kind of a special reference (I don't
like to call it like that to avoid too much confusion). Together with
the "normal" references it might even become reference->handle->object.
>So in the example code above
$a contains a copy of the object handle which was created beforehand,
while $b is a reference to that handle. That's a difference.

no, this is wholly wrong.

new object() creates an entry in the symbol table. that entry has a handle.
That entry _is_ the handle. The associated object can be stored
elsewhere (I don't know how the ZE handles this internally, doesn't
matter anyway).
>$foo becomes an alias for that handle.
An alias would be a reference, which is not the case here.
>$a gets a new handle in the symbol
table whereby the entry data is copied into it from $foo. $b is an alias of
$foo.
Let's look at it this way:

$foo = 5;

$a = $foo;
$b = &$foo;

Same thing. Let the 5 be the internal number (the handle) of any object.
The first assignment copies the symbol table entry of $foo into $a.
Both $foo and $a now contain the same value, but of course in different
symbol table positions - both values can be changed without affecting
the other. The second assignment doesn't make a copy, but instead makes
$b an alias/a reference to the symbol table entry of $foo:

$foo ----.
+---5
$b ----

$a --------5

This is a bit simplified and not exactly how it's done internally, but
it's how it behaves from the programmer's POV.
>$a is NOT a copy of the $foo's object handle - that would be an *alias*...a
*reference*.
$b is the reference, $a is the copy. Back to our object handle, the
situation would look like this:

$foo ----.
+---5 ----.
$b ---- +---object #5
|
$a --------5 ----

So if you now change $b to something else, it will also change $foo
because of the reference. But if you change $a, it will leave $b and
$foo untouched:

$foo ----.
+---5 --------object #5
$b ----

$a --------42
>Here's a background article regarding this issue (and some more):

You're being lied to.
http://blog.libssh2.org/index.php?/a...-lied-to..html

by whom, micha?
Mentioned in the first paragraph:

| If you're among the crowd who have migrated an OOP based application
| from PHP4 to PHP5, then I'm sure you've heard the expression "Objects
| are copied by reference by default in PHP5". Whoever told you that,
| was lying.

Micha
Dec 19 '07 #16

P: n/a
<cowers in the middle as flames go over his head>

So is this, my current understanding, correct?
$foo = new Test();
$a = $foo;
$b = &$foo;

$foo and $b are both pointing to the same thingie, which in turn
points to Test().
$a is pointing to a different thingie from $foo/$b, which in turn
points to Test().

Changing either $foo OR $b to point to a new thingie will result in
BOTH being changed.
Changing $a to point to a new thingie will leave $foo and $b
unaffected.

<looks hopeful>

Dec 19 '07 #17

P: n/a
..oO(Logos)
><cowers in the middle as flames go over his head>
Don't worry. In most cases it doesn't matter. But in some rare cases it
might. And then you're looking for an explanation ...

Two years ago this issue came up in a German PHP newsgroup, where a
particular script behaved in a strange and unexpected way. During the
discussion these issues with references and object handles came up. The
conclusion was, that PHP behaved as it should and the object handling
worked as expected. It is (or was) just described in a rather bad and
incomplete way in the manual, hence all the confusion.
>So is this, my current understanding, correct?
$foo = new Test();
$a = $foo;
$b = &$foo;

$foo and $b are both pointing to the same thingie, which in turn
points to Test().
$a is pointing to a different thingie from $foo/$b, which in turn
points to Test().
Yes, the behaviour could be described that way. As said - usually you
don't have to think about these issues.

As an addition: There's an old bug report and also a section in the
manual regarding this issue:

Objects are not being passed by reference
http://bugs.php.net/bug.php?id=32137

http://www.php.net/manual/en/languag...oop5.basic.new
>Changing either $foo OR $b to point to a new thingie will result in
BOTH being changed.
Yep, that's the nature of a reference.
>Changing $a to point to a new thingie will leave $foo and $b
unaffected.
Correct.

Micha
Dec 20 '07 #18

P: n/a
Steve wrote:
"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com...
>.oO(Logos)
>>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:

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.
js*******@attglobal.net
==================

Dec 27 '07 #19

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.com. ..
Steve wrote:
>"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com.. .
>>.oO(Logos)

On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:

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.
read, jerry, read. show me how in *PHP* the behavior is different. you've
tried before and failed. i'm not talking about the differences in c/c++/c#
(as they *are* different there)...we're talking about php.
Dec 31 '07 #20

P: n/a
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.com. ..
>Steve wrote:
>>"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com. ..
.oO(Logos)

On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>
>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.

read, jerry, read. show me how in *PHP* the behavior is different. you've
tried before and failed. i'm not talking about the differences in c/c++/c#
(as they *are* different there)...we're talking about php.
Stoopid. Show me where PHP has pointers. It doesn't.

And you're the one who claimed that references and pointers behave
identically in C/C++. Wrong again.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 31 '07 #21

P: n/a
..oO(Steve)
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.com ...
>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.

read, jerry, read. show me how in *PHP* the behavior is different.
All these things can't be done with references as they exist in PHP:

* pointer arithmetics
* pointer pointers
* working with the pointer itself or the value it points to (which is
the basis for the first two things)
* ...

There are _no_ pointers in PHP. A reference is _not_ a pointer.

And since PHP references behave identically to C++ references (both are
symbol table alias names), your statement above would also mean that C++
references behave identically to pointers as well. Would you tell that
to a C++ programmer?

Micha
Dec 31 '07 #22

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:V9******************************@comcast.com. ..
Steve wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.com ...
>>Steve wrote:
"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.com ...
.oO(Logos)
>
>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>
>>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.

read, jerry, read. show me how in *PHP* the behavior is different. you've
tried before and failed. i'm not talking about the differences in
c/c++/c# (as they *are* different there)...we're talking about php.

Stoopid. Show me where PHP has pointers. It doesn't.

And you're the one who claimed that references and pointers behave
identically in C/C++. Wrong again.
nope...i just said they were different in c, c++, and c#. i said for *PHP*
the behavior is essentially the same. i never said php had pointers...but
that the behavioral description is similar to pointers...and gave the
caveats about the actual terms and definitions so that is was clear that
there is technical difference.

learn to read.
Dec 31 '07 #23

P: n/a

"Michael Fesser" <ne*****@gmx.dewrote in message
news:el********************************@4ax.com...
.oO(Steve)
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.co m...
>>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.

read, jerry, read. show me how in *PHP* the behavior is different.

All these things can't be done with references as they exist in PHP:

* pointer arithmetics
* pointer pointers
* working with the pointer itself or the value it points to (which is
the basis for the first two things)
* ...

There are _no_ pointers in PHP. A reference is _not_ a pointer.

And since PHP references behave identically to C++ references (both are
symbol table alias names), your statement above would also mean that C++
references behave identically to pointers as well. Would you tell that
to a C++ programmer?
no, i wouldn't. again though micha, i explained that using the term
'pointer' for someone starting out in php makes understanding how aliasing
works a bit simpler.
Dec 31 '07 #24

P: n/a
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:V9******************************@comcast.com. ..
>Steve wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.co m...
Steve wrote:
"Michael Fesser" <ne*****@gmx.dewrote in message
news:0h********************************@4ax.co m...
>.oO(Logos)
>>
>>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>>
>>>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.
read, jerry, read. show me how in *PHP* the behavior is different. you've
tried before and failed. i'm not talking about the differences in
c/c++/c# (as they *are* different there)...we're talking about php.
Stoopid. Show me where PHP has pointers. It doesn't.

And you're the one who claimed that references and pointers behave
identically in C/C++. Wrong again.

nope...i just said they were different in c, c++, and c#. i said for *PHP*
the behavior is essentially the same. i never said php had pointers...but
that the behavioral description is similar to pointers...and gave the
caveats about the actual terms and definitions so that is was clear that
there is technical difference.

learn to read.
"i said for *PHP* the behavior is essentially the same."

"i never said php had pointers"

You're so dense you can't even see the contradiction on your own statements.

You're just a stoopid troll, Stevie, who uses people in a desperate
attempt to get some kind of acceptance. You don't use your real name
here because you're so afraid people will find out you're not really a
programmer.

But you're stoopidity has given you away once again. Any programmer
with more than two weeks of *real experience* in C++ programming knows
the difference between pointers and references - and knows how wrong you
are.

You're the worst kind of loser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 31 '07 #25

P: n/a
Michael Fesser wrote:
.oO(Steve)
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.com ...
>>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.
read, jerry, read. show me how in *PHP* the behavior is different.

All these things can't be done with references as they exist in PHP:

* pointer arithmetics
* pointer pointers
* working with the pointer itself or the value it points to (which is
the basis for the first two things)
* ...

There are _no_ pointers in PHP. A reference is _not_ a pointer.

And since PHP references behave identically to C++ references (both are
symbol table alias names), your statement above would also mean that C++
references behave identically to pointers as well. Would you tell that
to a C++ programmer?

Micha
Hi, Micha,

Forget Stevie. He's not worth it.

A more appropriate place for him would be alt.stoopid.trolls instead of
someplace real programmers hang out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 31 '07 #26

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:t-******************************@comcast.com...
Steve wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:V9******************************@comcast.com ...
>>Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.c om...
Steve wrote:
>"Michael Fesser" <ne*****@gmx.dewrote in message
>news:0h********************************@4ax.c om...
>>.oO(Logos)
>>>
>>>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>>>
>>>>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.
read, jerry, read. show me how in *PHP* the behavior is different.
you've tried before and failed. i'm not talking about the differences
in c/c++/c# (as they *are* different there)...we're talking about php.
Stoopid. Show me where PHP has pointers. It doesn't.

And you're the one who claimed that references and pointers behave
identically in C/C++. Wrong again.

nope...i just said they were different in c, c++, and c#. i said for
*PHP* the behavior is essentially the same. i never said php had
pointers...but that the behavioral description is similar to
pointers...and gave the caveats about the actual terms and definitions so
that is was clear that there is technical difference.

learn to read.

"i said for *PHP* the behavior is essentially the same."

"i never said php had pointers"

You're so dense you can't even see the contradiction on your own
statements.
*behavior*...context clue, dumbass.
You're just a stoopid troll, Stevie, who uses people in a desperate
attempt to get some kind of acceptance. You don't use your real name here
because you're so afraid people will find out you're not really a
programmer.
is that right.
But you're stoopidity has given you away once again. Any programmer with
more than two weeks of *real experience* in C++ programming knows the
difference between pointers and references - and knows how wrong you are.
php != c++ ... your point is moot.
You're the worst kind of loser.
is that anything like a dipshit who keeps posting the same drivel day after
day just to have someone to chat with? sounds more like you jerry than me.
Jan 1 '08 #27

P: n/a
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:t-******************************@comcast.com...
>Steve wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:V9******************************@comcast.co m...
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast. com...
>Steve wrote:
>>"Michael Fesser" <ne*****@gmx.dewrote in message
>>news:0h********************************@4ax. com...
>>>.oO(Logos)
>>>>
>>>>On Dec 13, 3:16 pm, Michael Fesser <neti...@gmx.dewrote:
>>>>>
>>>>>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.
read, jerry, read. show me how in *PHP* the behavior is different.
you've tried before and failed. i'm not talking about the differences
in c/c++/c# (as they *are* different there)...we're talking about php.
Stoopid. Show me where PHP has pointers. It doesn't.

And you're the one who claimed that references and pointers behave
identically in C/C++. Wrong again.
nope...i just said they were different in c, c++, and c#. i said for
*PHP* the behavior is essentially the same. i never said php had
pointers...but that the behavioral description is similar to
pointers...and gave the caveats about the actual terms and definitions so
that is was clear that there is technical difference.

learn to read.
"i said for *PHP* the behavior is essentially the same."

"i never said php had pointers"

You're so dense you can't even see the contradiction on your own
statements.

*behavior*...context clue, dumbass.
You're so dense you can't even see the contradiction in your own
statement, stoopid troll.

And if you're talking behavior, you've just shown you have no idea about
how to use pointer.

You've just once again opened your "mouth" and removed all doubt about
your stoopidity.
>You're just a stoopid troll, Stevie, who uses people in a desperate
attempt to get some kind of acceptance. You don't use your real name here
because you're so afraid people will find out you're not really a
programmer.

is that right.
Yep. You give yourself away virtually every time you respond to a post
here.
>But you're stoopidity has given you away once again. Any programmer with
more than two weeks of *real experience* in C++ programming knows the
difference between pointers and references - and knows how wrong you are.

php != c++ ... your point is moot.
Then why did you bring it up? Backpedaling again, stoopid troll?
>You're the worst kind of loser.

is that anything like a dipshit who keeps posting the same drivel day after
day just to have someone to chat with? sounds more like you jerry than me.
Just the truth, Stevie. But you can't handle it. You could always stop
responding. But I know you won't.

Now I hear your mommy calling. Better go see what she wants.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 1 '08 #28

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:t-******************************@comcast.com...
Michael Fesser wrote:
>.oO(Steve)
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:mJ******************************@comcast.co m...

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.
read, jerry, read. show me how in *PHP* the behavior is different.

All these things can't be done with references as they exist in PHP:

* pointer arithmetics
* pointer pointers
* working with the pointer itself or the value it points to (which is
the basis for the first two things)
* ...

There are _no_ pointers in PHP. A reference is _not_ a pointer.

And since PHP references behave identically to C++ references (both are
symbol table alias names), your statement above would also mean that C++
references behave identically to pointers as well. Would you tell that
to a C++ programmer?

Micha

Hi, Micha,

Forget Stevie. He's not worth it.
apparently 'worth it' enough for you to spend an exhorbidant amount of time
badgering. :)
A more appropriate place for him would be alt.stoopid.trolls instead of
someplace real programmers hang out.
well jerry, you're a teacher, not a programmer. so, double-entendre
intended, you can get lost.
Jan 2 '08 #29

P: n/a
..oO(Steve)
>rof! pointers DO exist.
Not in PHP. If you still insist on that, maybe you should file a bug
report, because the manual also says that references are no pointers ...
>if pointers DID exist in *PHP*, i'd have used a
different descriptive for references in *PHP*. but, i've already addressed
that...and your statement here is simply stupid as you leave out the context
for the claim 'doesn't exist'.
It doesn't matter how you personally define "pointer" and "reference",
you can name them whatever you like. But in computer science both terms
have a well-defined meaning and behaviour. And by these definitions PHP
references are _no_ pointers. It's that simple.

EOT for me
Micha
Jan 3 '08 #30

P: n/a

"Michael Fesser" <ne*****@gmx.dewrote in message
news:ck********************************@4ax.com...
.oO(Steve)
>>rof! pointers DO exist.

Not in PHP. If you still insist on that, maybe you should file a bug
report, because the manual also says that references are no pointers ...
i've been clear micha. pointers do NOT exist in php but DO exist in other
languages. the point was that jerry didn't specify the context - php or
other language.
>>if pointers DID exist in *PHP*, i'd have used a
different descriptive for references in *PHP*. but, i've already addressed
that...and your statement here is simply stupid as you leave out the
context
for the claim 'doesn't exist'.

It doesn't matter how you personally define "pointer" and "reference",
you can name them whatever you like. But in computer science both terms
have a well-defined meaning and behaviour. And by these definitions PHP
references are _no_ pointers. It's that simple.
which is fine. however, php noobs don't care about those particulars. and,
they seem to 'get it' faster describing it one way v. another.
Jan 3 '08 #31

This discussion thread is closed

Replies have been disabled for this discussion.