Re: Is this a php bug?
- From: SST <gcarras@xxxxxxx>
- Date: Fri, 29 Jun 2007 08:04:08 -0700
Hey friend, i don't agree with you.
We may always treat include/require as they include something into the
original file.
So if test1.php:
<?php
$a = 1;
?>
test2.php is:
<?php
include 'test1.php';
print $a;
?>
We may treat test2.php as:
<?php
$a = 1;
print $a;
?>
So let's look at test1/test2/test3. If we treat test3 as:
[yarco@localhost test]$ cat test3.php
<?php
class B implements C
{
}
interface C
{
}
class A extends B
{
}
?>[yarco@localhost test]$ php test3.php
[yarco@localhost test]$
It certainly could work fine. So i don't think it should give an error
when i do that.
And __autoload also does't give me any help.
On 6 29 , 10 28 , ZeldorBlat <zeldorb...@xxxxxxxxx> wrote:
On Jun 29, 9:49 am, Yarco <yarc...@xxxxxxxxx> wrote:
[yarco@localhost test]$ cat test1.php
<?php
interface C
{
}
class A extends B
{
}
?>[yarco@localhost test]$ cat test2.php
<?php
class B implements C
{
}
?>[yarco@localhost test]$ cat test3.php
<?php
require_once dirname(__FILE__).'/test2.php';
require_once dirname(__FILE__).'/test1.php';
?>[yarco@localhost test]$ php test3.php
PHP Fatal error: Interface 'C' not found in /home/yarco/Projects/test/
test2.php on line 3
[yarco@localhost test]$ php -v
PHP 5.2.1 (cli) (built: Jun 3 2007 12:45:11)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Think about what's happening here. You include test2.php first. That
declares class B which implements interface C. But interface C is
defined in test1.php which hasn't been included yet, so the interface
is undefined.
Read about __autoload:
<http://www.php.net/autoload>
.
- Follow-Ups:
- Re: Is this a php bug?
- From: ZeldorBlat
- Re: Is this a php bug?
- References:
- Is this a php bug?
- From: Yarco
- Re: Is this a php bug?
- From: ZeldorBlat
- Is this a php bug?
- Prev by Date: RE: [PHP] RE: Address book - LDAP or MySQL?
- Next by Date: Re: Is this a php bug?
- Previous by thread: Re: Is this a php bug?
- Next by thread: Re: Is this a php bug?
- Index(es):
Relevant Pages
|