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

From: Date: Tue, 21 Nov 2006 11:44:52 +0000
Subject: #39567 [Bgs->Opn]: Cannot find Class definition when there is one
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105248@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 +Status: Open Bug Type: Class/Object related Operating System: WinXp sp2+Apache2.2+Mod_PHP PHP Version: 5.2.0 New Comment: 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... Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2006-11-21 11:21:27] imkow at 163 dot com i have changed my code to absolute path. require("F:/LXH/Webs/pware/file2.php"); $k= new B; class B extends A{} the problem is still there. a fatal error was thrown out. ------------------------------------------------------------------------ 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 (#105248) next »