note 76239 added to language.oop5.abstract
| From: | Wes at osu1 dot php dot net | Date: | Fri, 06 Jul 2007 21:29:24 +0000 |
| Subject: | note 76239 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128272@lists.php.net to get a copy of this message | ||
a simple solution to write an abstract class with the constructor predefinition
interface MyBaseClassAbstract
{
public pleaseDefineThisMethod();
}
class MyBaseClass
{
function __construct()
{
if(get_class($this) == __CLASS__)
throw new Exception("you can't instantiate this class");
else
{
//common constructor
}
}
}
class MyClass extends MyBaseClass implements MyBaseClassAbstract
{
function pleaseDefineThisMethod()
{
echo "hello";
}
}
$test = new MyClass();
$test = new MyBaseClass(); // error!
----
Server IP: 213.92.11.19
Probable Submitter: 87.2.191.113
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/76239
Del: integrated -- https://master.php.net/note/delete/76239/integrated
Del: useless -- https://master.php.net/note/delete/76239/useless
Del: bad code -- https://master.php.net/note/delete/76239/bad+code
Del: spam -- https://master.php.net/note/delete/76239/spam
Del: non-english -- https://master.php.net/note/delete/76239/non-english
Del: in docs -- https://master.php.net/note/delete/76239/in+docs
Del: other reasons-- https://master.php.net/note/delete/76239
Reject -- https://master.php.net/note/reject/76239
Search -- https://master.php.net/manage/user-notes.php