ID: 13165
Comment by: [EMAIL PROTECTED]
Old Reported By: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Analyzed
Bug Type: Documentation problem
Operating System: RedHat 7.1
PHP Version: 4.0.6
New Comment:

Isn't this the same bug as http://bugs.php.net/bug.php?id=13882 (and
therefore solved in version 4.1.1?)

if not it still seems a bug to me: whenever A includes B and B includes
C, it should not be necessary that A has to include C


Previous Comments:
------------------------------------------------------------------------

[2001-10-21 20:49:20] [EMAIL PROTECTED]

This is not a bug. Classes must be defined in order.
They can be in different order if they are in same file 
though. (Zeev can explain this better :)

Reclassified as documentation problem as this isn't 
explained anywhere.

--Jani


------------------------------------------------------------------------

[2001-09-11 01:18:21] [EMAIL PROTECTED]

Just wondering if there has been any progress on this report?  Thanks.

------------------------------------------------------------------------

[2001-09-06 02:11:38] [EMAIL PROTECTED]

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?

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=13165&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to