I have a class instance $obj = new class
. obj
is actually a variable from another object so it's more like $obj1->obj2->obj3 = new class
. This is making my code a little confusing so I want to do something like:
$var =& $obj1->obj2->obj3 = new class
and then start using this instance as
$var->method()
or $var->name = 'abc'
.
When using it like $var = $obj1->obj2->obj3 = new class
it works just fine but I was thinking about the memory I could save (as the object is quite large and duplicating it would not be advisable). I'm not sure if this is an issue or if it actually necessary to assign by reference or if PHP takes this into consideration.
I forgot to mention, using $var =& $obj1->obj2->obj3 = new class
results in:
Parse error: syntax error, unexpected '='