oop - How do I access class variables of a parent object in PHP? -
an instance of class instantiates couple of other objects, example class b:
$foo = new b();
i access a's public class variables methods within b.
unless i'm missing something, way pass current object instances of b:
$foo = new b($this);
is best practice or there way this?
that looks fine me, tend use rule of thumb of "would maintaining understand it?" , that's understood solution.
if there's 1 "a", consider using registry pattern, see example http://www.phppatterns.com/docs/design/the_registry
Comments
Post a Comment