-> or :: ?

a_at_b.c
Date: 07/13/04


Date: Tue, 13 Jul 2004 11:56:13 +0200

hi all,

I'm a bit confused with this and I hope you can help me:

I have a "Mother" class and a "child" that extends Mother.
The child's constructor should call Mother's constructor.

Now the question is:
How should child's constructor call mother's constructor?
a) Mother::Mother();
b) $this->Mother();

I guess the second way is the right one, but I'm confused because:
1) both methods work;
2) both methods are in the manual;

can you help me to understand this (so I can sleep again ;-) )?

TIA
FR

----
The code:
<?php
class Mother
{
   var $v;
   function Mother()
   {
     echo "I'm the Mother<br>\n";
     $this->v=1;
   }
}
class ChildA extends Mother
{
   function ChildA()
   {
     Mother::Mother();             // <--- is this correct? why?
     echo "I'm the childA<br>\n";
   }
}
class ChildB extends Mother
{
   function ChildB()
   {
     $this->Mother();             // <--- is this correct? why?
     echo "I'm the childB<br>\n";
   }
}
$a=new childA();
$b=new childB();
echo "\$a->v: $a->v<br>\n";
echo "\$b->v: $b->v<br>\n";
?>