Re: Inherited and unimplemented method of a class
| From: | Aspra Flavius Adrian | Date: | Tue, 29 Apr 2008 14:38:55 +0000 |
| Subject: | Re: Inherited and unimplemented method of a class | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273701@lists.php.net to get a copy of this message | ||
On Tue, Apr 29, 2008 at 4:29 PM, Stut <stuttle@gmail.com> wrote:
>
>
> On 29 Apr 2008, at 15:19, Aspra Flavius Adrian wrote:
>
>
> > Hello folks.
> >
> > An inherited and unimplemented method of a class in PHP-5.2.5 gets called
> twice:
> >
> > class Foo {
> > public function foo() {
> > echo get_class($this);//or __CLASS__;
> > }
> > }
> > class Bar extends Foo {
> > }
> > $f = new Bar;
> > $f->foo();
> >
> > Shouldn't it be only once? If I'm doing something wrong, how would I
> > do it right? If it's a bug, did it get fixed as of 5.2.6RC5 ?
> >
>
> PHP supports two types of constructor. One is __construct(), the other is a
> function with the same name as the class.
Oh, yeah, I've got so used with php 5 that I've completly forgot about
php 4 compatibility
>
> In your example new Bar; will call foo as the constructor for the Foo
> class, and then you call foo again explicitly.
>
Thanks.
> -Stut
>
> --
> http://stut.net/
>