Edit report at https://bugs.php.net/bug.php?id=65229&edit=1
ID: 65229 Comment by: cmbecker69 at gmx dot de Reported by: odiel dot leon at gmail dot com Summary: Fatal error using class Inheritance Status: Open Type: Bug Package: Class/Object related Operating System: Ubuntu 12.04.1 LTS PHP Version: 5.4.17 Block user comment: N Private report: N New Comment: This is not a bug, as it is clearly documented on <http://www.php.net/manual/en/language.oop5.inheritance.php>: | Unless autoloading is used, then classes must be defined before | they are used. If a class extends another, then the parent | class must be declared before the child class structure. This | rule applies to classes that inherit other classes and interfaces. Previous Comments: ------------------------------------------------------------------------ [2013-07-09 21:21:55] odiel dot leon at gmail dot com Description: ------------ PHP is generating a fatal error when a class that inherit from another is getting instantiated and these classes are defined after being instantiated. If the class does not inherit PHP run the code without errors. Test script: --------------- <?php $a = new Aa(); $a->hi(); class Aa extends Bb { } class Bb { public function hi() { echo('hi Aa'); } } Expected result: ---------------- hi Aa Actual result: -------------- PHP Fatal error: Class 'Aa' not found in /home/www/test.php on line 3 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65229&edit=1