You are here: Re: abstract classes and inheritance in php5 « PHP Language « IT news, forums, messages
Re: abstract classes and inheritance in php5

Posted by Janwillem Borleffs on 05/29/05 01:55

Janwillem Borleffs wrote:
> Not possible, because only the class that extends the abstract class
> is forced to implement the method.
>
> Other classes just inherit the method.
>

However, there is a way using the Reflection API:

abstract class Foo {
final function __construct() {
$rm = new ReflectionMethod($this, 'init');
if (get_class($this) != $rm->getDeclaringClass()->getName()) {
throw new Exception("init() method must be implemented");
}
}
abstract function init();
}

But be aware that using the Reflection API in production applications can
have a negative impact on performance.


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация