| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2001-09-11 01:18 UTC] colin at maven dot com dot au
  [2001-10-21 20:49 UTC] sniper@php.net
  [2002-01-17 17:27 UTC] eye at eye-home dot net
  [2002-06-10 04:43 UTC] mfischer@php.net
  | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 00:00:01 2025 UTC | 
There is *definately* a problem in PHP 4.0.6 with classes, inheritance, and included/required files. Here is an example: // ====================== // test.php: <?php include("children.php"); ?> // ====================== // ====================== // children.php <?php include_once("parent.php"); class Child2 extends Child1 { } class Child1 extends Parent { } ?> // ====================== // ====================== // parent.php <?php class Parent { } ?> // ====================== You can try this out for yourself and see what I mean. If you bring up "test.php" in your browser, you should receive this error: Fatal error: Class child2: Cannot inherit from undefined class child1 Why does this happen, even though all files are being included correctly? Well, I know one way of preventing the error, and that is by re-ordering the classes in "children.php" so that Child1() is listed first. This removes the error, **however**, if the Parent() class is NOT in a separate file, and is actually part of the same file (i.e. "children.php"), the order of the class definitions does NOT matter. Why is this?