#39567 [Bgs]: Cannot find Class definition when there is one
| From: | imkow at 163 dot com | Date: | Tue, 21 Nov 2006 12:11:09 +0000 |
| Subject: | #39567 [Bgs]: Cannot find Class definition when there is one | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105250@lists.php.net to get a copy of this message | ||
ID: 39567
User updated by: imkow at 163 dot com
Reported By: imkow at 163 dot com
Status: Bogus
Bug Type: Class/Object related
Operating System: WinXp sp2+Apache2.2+Mod_PHP
PHP Version: 5.2.0
New Comment:
All right. but you people have to notice this is still a design fault
that should be addressed in somewhere. we php script developers don't
know much about php's internal structure. we can hardly distinguish
what is done in compile time and what is not. The problem isn't on the
manual where you can learn. So people will be used to write code like
this until something be pointed out or changed.
Previous Comments:
------------------------------------------------------------------------
[2006-11-21 11:49:29] tony2001@php.net
No, I didn't mean this.
I meant exactly what I said - there is no way to declare this class in
compile time, so it's declared in runtime.
And you get the error because you're trying to use the class which is
not yet declared.
Please keep this report a bogus. Thank you.
------------------------------------------------------------------------
[2006-11-21 11:44:52] imkow at 163 dot com
do you mean that it's forbidden to write code like
within one file:
class A{}
$j=new B;
class B extends A{}
or code like:
$j=new B;
class B{}
is also forbidden.
But at this moment they all work fine in php. if those mentioned are
forbidden, maybe we should write something in the manual to clarify
this...
------------------------------------------------------------------------
[2006-11-21 11:42:44] tony2001@php.net
Please read what I said in my previous comment.
------------------------------------------------------------------------
[2006-11-21 11:34:51] imkow at 163 dot com
require("file1.php");
$j= new A;
$k= new B;
class B extends A{}
I've changed the code to ensure class A is defined.
as shown above, only the line where $k in throws error..
------------------------------------------------------------------------
[2006-11-21 11:33:28] tony2001@php.net
Expected behaviour.
Class "B" cannot be declared in compile time, because class "A" is
declared in another file.
But in runtime, when you execute the line "$obj=new B;", the class "B"
doesn't exist yet.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39567
--
Edit this bug report at http://bugs.php.net/?id=39567&edit=1