Re: Is this a php bug?
- From: Yarco <yarco.w@xxxxxxxxx>
- Date: Fri, 29 Jun 2007 08:21:11 -0700
And when i use function declaration replace with interface and class,
it works fine. See below:
[yarco@localhost test]$ cat test1.php
<?php
function test1()
{
test2();
}
?>
[yarco@localhost test]$ cat test2.php
<?php
function test2()
{
}
?>
[yarco@localhost test]$ cat test3.php
<?php
require_once dirname(__FILE__).'/test1.php';
require_once dirname(__FILE__).'/test2.php';
?>
[yarco@localhost test]$ php test3.php
[yarco@localhost test]$
If it works as you said, this can not happen.
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] shuffle or mt_rand
- 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
|