Ask a Question related to PHP Bugs, Design and Development.
-
imkow at 163 dot com #1
#39567 [NEW]: Cannot find Class definition when there is one
From: imkow at 163 dot com
Operating system: WinXp sp2+Apache2.2+Mod_PHP
PHP version: 5.2.0
PHP Bug Type: Class/Object related
Bug description: Cannot find Class definition when there is one
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
--
Edit bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=39567&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=39567&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=39567&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=39567&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=39567&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=39567&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=39567&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=39567&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=39567&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=39567&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=39567&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=39567&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=39567&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=39567&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=39567&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=39567&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=39567&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=39567&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=39567&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=39567&r=mysqlcfg[/url]
imkow at 163 dot com Guest
-
How to automatically add class definition to proxy
I defined two typis in asmx file (.Net/C#/WebService): Class Parent { } Class ChildOne: Parent { } -
#25377 [Bgs]: Class variables can be added out of class definition
ID: 25377 Updated by: helly@php.net Reported By: forseti at oak dot rpg dot pl Status: Bogus Bug Type: ... -
#25377 [Opn->Bgs]: Class variables can be added out of class definition
ID: 25377 Updated by: sniper@php.net Reported By: forseti at oak dot rpg dot pl -Status: Open +Status: ... -
Where can I find the IPTC definition?
I am looking for the (official) definition of the IPTC-tags. I have searched www.iptc.org but all I could find was documents on their news... -
Magic at class-definition time
In an interview on http://www.codegeneration.net/>, Pragmatic Dave showed some interesting tricks. The article has a long URL, so use... -
tony2001@php.net #2
#39567 [Opn->Fbk]: Cannot find Class definition when there is one
ID: 39567
Updated by: [email]tony2001@php.net[/email]
Reported By: imkow at 163 dot com
-Status: Open
+Status: Feedback
Bug Type: Class/Object related
Operating System: WinXp sp2+Apache2.2+Mod_PHP
PHP Version: 5.2.0
New Comment:
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
Previous Comments:
------------------------------------------------------------------------
[2006-11-21 09:55:38] imkow at 163 dot com
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
tony2001@php.net Guest
-
imkow at 163 dot com #3
#39567 [Fbk->Opn]: Cannot find Class definition when there is one
ID: 39567
User updated by: imkow at 163 dot com
Reported By: imkow at 163 dot com
-Status: Feedback
+Status: Open
Bug Type: Class/Object related
Operating System: WinXp sp2+Apache2.2+Mod_PHP
PHP Version: 5.2.0
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2006-11-21 10:16:07] [email]tony2001@php.net[/email]
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
------------------------------------------------------------------------
[2006-11-21 09:55:38] imkow at 163 dot com
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
imkow at 163 dot com Guest
-
imkow at 163 dot com #4
#39567 [Opn]: Cannot find Class definition when there is one
ID: 39567
User updated by: imkow at 163 dot com
Reported By: imkow at 163 dot com
Status: Open
Bug Type: Class/Object related
Operating System: WinXp sp2+Apache2.2+Mod_PHP
PHP Version: 5.2.0
New Comment:
require("F:/LXH/Webs/pware/file1.php");
a correction, it was file1.php, not file2.php
but im sure the problem is still there.
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2006-11-21 10:16:07] [email]tony2001@php.net[/email]
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
------------------------------------------------------------------------
[2006-11-21 09:55:38] imkow at 163 dot com
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
imkow at 163 dot com Guest
-
tony2001@php.net #5
#39567 [Opn->Bgs]: Cannot find Class definition when there is one
ID: 39567
Updated by: [email]tony2001@php.net[/email]
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:
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.
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2006-11-21 10:16:07] [email]tony2001@php.net[/email]
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
------------------------------------------------------------------------
[2006-11-21 09:55:38] imkow at 163 dot com
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
tony2001@php.net Guest
-
imkow at 163 dot com #6
#39567 [Bgs->Opn]: Cannot find Class definition when there is one
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:
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..
Previous Comments:
------------------------------------------------------------------------
[2006-11-21 11:33:28] [email]tony2001@php.net[/email]
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.
------------------------------------------------------------------------
[2006-11-21 10:16:07] [email]tony2001@php.net[/email]
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
------------------------------------------------------------------------
[2006-11-21 09:55:38] imkow at 163 dot com
Description:
------------
Two files:
file1.php:
class A{}
file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
when runing file2.php, it throws a Fatal Error, saying Class B can't be
found in the line where "$obj=new B;" is.
But, in following code, things will just be fine:
class A{}
$obj=new B;
class B extends A{}
I use an official release of PHP 5.2.0 under windows. All mods are also
from Pecl.
Reproduce code:
---------------
//file1.php:
class A{}
//file2.php:
require("file1.php");
$obj=new B;
class B extends A{}
Expected result:
----------------
nothing..
Actual result:
--------------
( ! ) Fatal error: Class 'B' not found in file2.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
imkow at 163 dot com Guest
-
tony2001@php.net #7
#39567 [Opn->Bgs]: Cannot find Class definition when there is one
ID: 39567
Updated by: [email]tony2001@php.net[/email]
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:
Please read what I said in my previous comment.
Previous Comments:
------------------------------------------------------------------------
[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] [email]tony2001@php.net[/email]
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.
------------------------------------------------------------------------
[2006-11-21 10:16:07] [email]tony2001@php.net[/email]
Please change require("file1.php"); to
require("/absolute/path/to/file1.php"); and see if it works.
------------------------------------------------------------------------
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
[url]http://bugs.php.net/39567[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
tony2001@php.net Guest
-
imkow at 163 dot com #8
#39567 [Bgs->Opn]: Cannot find Class definition when there is one
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] [email]tony2001@php.net[/email]
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] [email]tony2001@php.net[/email]
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
[url]http://bugs.php.net/39567[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
imkow at 163 dot com Guest
-
tony2001@php.net #9
#39567 [Opn->Bgs]: Cannot find Class definition when there is one
ID: 39567
Updated by: [email]tony2001@php.net[/email]
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] [email]tony2001@php.net[/email]
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] [email]tony2001@php.net[/email]
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
[url]http://bugs.php.net/39567[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
tony2001@php.net Guest
-
imkow at 163 dot com #10
#39567 [Bgs]: Cannot find Class definition when there is one
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] [email]tony2001@php.net[/email]
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] [email]tony2001@php.net[/email]
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] [email]tony2001@php.net[/email]
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
[url]http://bugs.php.net/39567[/url]
--
Edit this bug report at [url]http://bugs.php.net/?id=39567&edit=1[/url]
imkow at 163 dot com Guest



Reply With Quote

