views:

66

answers:

2
+2  Q: 

PHP Classes Extend

I have two classes that work seperate from another, but they extend the same class. Is it possible to have them work the same instance of the extended class. I'm wanting the constructor of the extended class to run only once.

I know this isn't right but something like this:

<?php
$oApp = new app;
class a extends $oApp {}
class b extends $oApp {}
A: 

What you want is this:

<?php
$oApp = new app;
class a extends app{}
class b extends app{}

If you have __constructors in the child classes, make sure that they call parent::__constructor, otherwise they will probably not work properly.

SeanJA
See: http://php.net/manual/en/keyword.extends.php
SeanJA
That I get. Was curious if I'm missing on classes. What I'm trying to achieve is along the lines of having the app constructor only sending one email when two classes extend it instead of an email per extend.
John Hoover
+2  A: 
SeanJA