note 97702 deleted from language.references.arent by danbrown
| From: | danbrown@php.net | Date: | Tue, 04 May 2010 14:15:48 +0000 |
| Subject: | note 97702 deleted from language.references.arent by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168926@lists.php.net to get a copy of this message | ||
Note Submitter: russrobinson at tectite dot com
----
In my previous post I said:
"It is my view that object references in PHP5 are exactly like pointers in C++."
"exactly like" is misleading...
To clarify:
I don't mean PHP5 object references support pointer arithmetic or they contain memory
addresses.
I mean that, in PHP5, when you pass object variables to functions they *behave* exactly like
pointers to objects do in the same situation when writing in C++ (with the exception of the C++
features that just don't exist in PHP, such as pointer arithmetic).
Namely,
1. When you pass the object variable, the formal parameter behaves like a C++ pointer to the object
inside the function.
2. When you pass the object variable by reference, the formal parameter behaves like a C++ reference
to a pointer to the object inside the function.
The syntax is different between the languages, but the semantics are identical.