note 115616 added to language.oop5.inheritance
| From: | ghoucine at gmail dot com | Date: | Tue, 26 Aug 2014 20:48:25 +0000 |
| Subject: | note 115616 added to language.oop5.inheritance | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200316@lists.php.net to get a copy of this message | ||
For multiple single inheretance to work the order of class definition is very important if
you're going up more than two levels in inheretence.
This won't work:
<?php
class A extends B {}
class B extends C {}
class C {}
$A = new A;
?>
Running the code above will spit a fatal error (Fatal Error:Class 'B' not found)
A change in class definition order will fix this:
<?php
class A extends B {}
class C {}
class B extends C {}
$A = new A;
?>
If you're goin up just one level in inhertance though there shouldn't be any problem. So
this code works too:
<?php
class A extends B {}
class B {}
$A = new A;
?>
I have no explanation as to why this is the case though.
----
Server IP: 72.52.91.14
Probable Submitter: 41.99.77.249
----
Manual Page -- http://php.net/manual/en/language.oop5.inheritance.php
Edit -- https://master.php.net/note/edit/115616
Del: integrated -- https://master.php.net/note/delete/115616/integrated
Del: useless -- https://master.php.net/note/delete/115616/useless
Del: bad code -- https://master.php.net/note/delete/115616/bad+code
Del: spam -- https://master.php.net/note/delete/115616/spam
Del: non-english -- https://master.php.net/note/delete/115616/non-english
Del: in docs -- https://master.php.net/note/delete/115616/in+docs
Del: other reasons-- https://master.php.net/note/delete/115616
Reject -- https://master.php.net/note/reject/115616
Search -- https://master.php.net/manage/user-notes.php