strangeness with include/require and classes
| From: | Chuck Hagenbuch | Date: | Wed, 21 Jul 1999 16:48:32 +0000 |
| Subject: | strangeness with include/require and classes | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-8907@lists.php.net to get a copy of this message | ||
Ok, this one's a bit bizarre. PHP4 Beta 1, running as an apache module
(1.3.6) on RH 6.0, compiled with imap support.
Here's the test script:
test.php3:
<?php
include 'class.inc';
require 'class2.inc';
$foo = new Bar2();
echo 'foo';
?>
class.inc:
<?php
class Bar {
function Bar () {
}
}
?>
class2.inc:
<?php
class Bar2 extends Bar {
var $parent;
function Bar2 () {
$this->Bar();
}
}
?>
In php3, this works fine. In php4, I get this:
Fatal error: Class bar2: Cannot inherit from undefined class bar in
class2.inc on line 7
If both classes are required, both included, *or* the first required and the
second included, it works fine. It only happens when the include comes first.
Can this be fixed?
-chuck
--
Charles Hagenbuch, <chagenbu@wso.williams.edu>
--
"look at how many toes i have!" - amy