Re: php5 and objects
| From: | Krzysztof Gorzelak | Date: | Wed, 28 Jul 2004 20:02:34 +0000 |
| Subject: | Re: php5 and objects | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192127@lists.php.net to get a copy of this message | ||
Uzytkownik "Curt Zirzow" <php-general@zirzow.dyndns.org> napisal w
wiadomosci
> * Thus wrote Krzysztof Gorzelak:
> > // start of code
> > abstract class Strona {
> >
> > abstract public function generuj_strone();
> >
> > function foo() {
> > generuj_strone();
> > }
> > }
> >
> > class Katalog extends Strona {
> > public function generuj_strone() {
> > echo "OK";
> > }
> >
> > }
> >
> > $bar = new Katalog();
> > $bar->foo();
> > // end of code
> > And I get such error :
> > Fatal error: Cannot call abstract method Strona::generuj_strone() in
....
> >
> > And I expect word: OK
> > Is it a bug or a normal behaviour ?
>
> It may be a bug, but not in the sense as your probably think. The
> error message should be complaining about an undefined function
> instead of trying to access self::generuj_strone()
>
> In foo() use:
> $this->generuj_strone();
>
> That will make things work properly
>
> Curt
Thank's, all works fine.
There is also no bug - in my previous version I had self::generuj_strone();
not generuj_strone(); as I wrote.
Thanks a lot
Krzysztof Gorzelak
krzysztof@uno.pl