#39567 [Opn->Bgs]: Cannot find Class definition when there is one

From: Date: Tue, 21 Nov 2006 11:49:29 +0000
Subject: #39567 [Opn->Bgs]: Cannot find Class definition when there is one
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105249@lists.php.net to get a copy of this message
ID: 39567 Updated by: tony2001@php.net Reported By: imkow at 163 dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: WinXp sp2+Apache2.2+Mod_PHP PHP Version: 5.2.0 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2006-11-21 11:26:18] imkow at 163 dot com require("F:/LXH/Webs/pware/file1.php"); a correction, it was file1.php, not file2.php but im sure the problem is still there. ------------------------------------------------------------------------ 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

« previous php.bugs (#105249) next »