note 106140 added to language.oop5.abstract
| From: | darkmantis at cybershade dot org | Date: | Thu, 13 Oct 2011 16:25:36 +0000 |
| Subject: | note 106140 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183852@lists.php.net to get a copy of this message | ||
This may be irrelevant to you, but I just had an idea about âabstractâ classes and the
âfinalâ keyword. If you declare a class as abstract and the constructor of that class as
final, then the extending class will not work:
<?php
abstract class newClass{
final public function __construct(){
echo 'You failed xD';
}
}
class MyClass extends newClass{
public function __construct(){
echo 'Will this work?';
}
public static function myFunc(){
echo 'FooBar';
}
}
$init = new MyClass();
$init::myFunc();
?>
And that will return :
Fatal error: Cannot override final method newClass::__construct() in
C:\wamp\Projects\BMPortal\public_html\newPHPClass.php on line 16
----
Server IP: 87.124.126.108
Probable Submitter: 93.97.240.97 (proxied: 93.97.240.97)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/106140
Del: integrated -- https://master.php.net/note/delete/106140/integrated
Del: useless -- https://master.php.net/note/delete/106140/useless
Del: bad code -- https://master.php.net/note/delete/106140/bad+code
Del: spam -- https://master.php.net/note/delete/106140/spam
Del: non-english -- https://master.php.net/note/delete/106140/non-english
Del: in docs -- https://master.php.net/note/delete/106140/in+docs
Del: other reasons-- https://master.php.net/note/delete/106140
Reject -- https://master.php.net/note/reject/106140
Search -- https://master.php.net/manage/user-notes.php