Bug #65229 [Opn->Nab]: Fatal error using class Inheritance
| From: | laruence@php.net | Date: | Wed, 10 Jul 2013 03:21:32 +0000 |
| Subject: | Bug #65229 [Opn->Nab]: Fatal error using class Inheritance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180170@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65229&edit=1
ID: 65229
Updated by: laruence@php.net
Reported by: odiel dot leon at gmail dot com
Summary: Fatal error using class Inheritance
-Status: Open
+Status: Not a bug
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:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
as cmbecker69 said
Previous Comments:
------------------------------------------------------------------------
[2013-07-09 23:28:46] cmbecker69 at gmx dot de
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.
------------------------------------------------------------------------
[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