note 33772 added to language.oop
| From: | barend at maximedia dot nl | Date: | Mon, 07 Jul 2003 14:30:40 +0000 |
| Subject: | note 33772 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51629@lists.php.net to get a copy of this message | ||
PHP doesn't know abstract classes, it'll always let you instantiate any defined class. Not
a critical problem if you (and your staff) are disciplined, but if you want to enforce it,
here's a simple way to do so from the constructor:
class AbstractClass {
....function AbstractClass() {
........assert( is_subclass_of($this, 'AbstractClass') );
........// remainder of constructor code
....}
}
Any subclass of AbstractClass can be instantiated, but trying to instantiate AbstractClass itself
results in an assertion failure.
----
Manual Page -- http://www.php.net/manual/en/language.oop.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33772
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33772&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33772&report=yes