|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54708 Fatal error by defined class with inheritance and wrong order and including
Submitted: 2011-05-11 12:30 UTC Modified: 2017-01-02 14:35 UTC
Avg. Score:3.7 ± 1.3
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:0 (0.0%)
From: interrobang at noicq dot org Assigned:
Status: Open Package: Class/Object related
PHP Version: Irrelevant OS: Debian Squeeze
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
16 + 47 = ?
Subscribe to this entry?

 [2011-05-11 12:30 UTC] interrobang at noicq dot org
Script "test.php" produces Fatal error in relation of writing order of classes.

If that missing class defined in same file, at the same place like require_once() (by replacing), no error will appear :O

Test script:
class file: test.class.php
class formularEssentials{}

main file: test.php
require_once 'test.class.php'; //contain "formularEssentials"
class formularBeta extends formularAlpha{}
class formularAlpha extends formularEssentials{}

Expected result:
nothing, blank screen. No "Fatal error" should be displayed.

Actual result:
Fatal error: Class 'formularAlpha' not found in test.php


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-09 21:37 UTC] pov at fingerprint dot fr
Other weird comportment with probably the same origin :

<?php // test.php
require 'test2.php';

<?php // test2.php
if (true) {
class SimpleFoo {

Expected result : no error
Actual result : "Cannot redeclare class SimpleFoo"
 [2017-01-02 14:35 UTC]
-Type: Bug +Type: Feature/Change Request
 [2017-01-02 14:35 UTC]
There are a number of variations on this. Here it's an unknown parent class, the two bugs I've just marked as duplicates us an interface. The same happens for used traits.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Nov 30 09:03:35 2021 UTC