a question for anyone who knows. The PHP documentation (for php5) clearly states that you don't pass objects by references in php, because for a method that accepts an object, the value actually being passed is an "object identifier which allows object accessors to find the actual object". The question is, what is happening when you actually do do this?
Consider the following code:
<?php
function foo(&$arg){
if(is_array($arg)){
print $arg['foo'];
}
if(is_object($arg)){
print $arg->{'foo'};
}
}
$o1 = new \stdClass;
$o1->foo = 'bar';
$a1 = ['foo'=>'bar'];
print sprintf("O1 foo: %s", foo($o1));
print sprintf("a1 foo: %s", foo($a1));
This correctly outputs:
o1 foo: bar
a1 foo: bar
The question is why? Can anyone describe what's happening with this object identifier reference that still allows accessing the actual object?