I'm only a greenhorn PHP programmer, and a veteran intermediate C++ programmer. So it seemed to make sense to me to have a code block like this:
Code: Select all
$caveman = &$Bedrock["Flintstone"];
Bowl($caveman);
AttendWaterbuffaloMeeting($caveman);
FakeIllness($caveman);
...A colleague of mine, who is a novice PHP programmer, told me that in his experience this would not be optimal at all. I found this very hard to understand, assuming that the under the hood, a reference in PHP references the data directly. If my friend is right, that would imply something very primitive like a PHP reference references the complex dereference operation, and therefore in dereferencing a reference, the associative array is dereferences 3 times! So how does it work?