Re: working with class inheritance
| From: | Jeff Taylor | Date: | Tue, 20 Mar 2007 08:54:06 +0000 |
| Subject: | Re: working with class inheritance | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250890@lists.php.net to get a copy of this message | ||
I forgot to mention that I have some __construct operations in the parent
class, and I want to add to those (and overwrite sometimes) in the child
class __construct
.... i.e Parent class __construct
$this->foo = 'Bar';
$this->foo2 = '10';
Child class __construct
$this->foo.='Bar';
$this->foo2 .= rand(1,6);
$this->type = 'Child';
Outputs of variables foo == Bar Bar
foo2 == 11-16
type == Child
Thanks :)
""Jeff Taylor"" <jefftaylor@optusnet.com.au> wrote in message
news:4F.F2.40101.20D9FF54@pb1.pair.com...
> OOPS!... typo
>
> Please replace implements with extends:
>
> class Child extends Parent
>
> Sorry about that
> ""Jeff Taylor"" <jefftaylor@optusnet.com.au> wrote in message
> news:A1.92.40101.DAC9FF54@pb1.pair.com...
> > Hey all, got a slight problem, where for some reasons my variables dont
> seem
> > to be getting stored in the child class:
> >
> > e.g
> >
> > class Parent
> > {
> > $private type;
> >
> > public function __construct()
> > {
> > }
> >
> > public function GetType()
> > {
> > return $this->type;
> > }
> > }
> >
> > class Child implements Parent
> > {
> > $public function __construct()
> >
> >
> > $this->type= 'Child';
> > }
> > }
> >
> > $Child= new Child();
> > echo $Child->getType;
> >
> > Can u see any reason why the type would return null?
> >
> > Thanks,
> >
> > Jeff
> >