php-groups.com | Post Question | Search | About | Groups | Contact | Register | Login


New in This Group

Session hanling & and disable disabled
3/8/2003 6:50:26 AM

Text>Image
3/8/2003 2:46:54 AM

Apache being mean to sessions?
3/5/2003 4:52:58 PM

num string format
3/2/2003 10:15:42 PM

General Speed and Server Caching
3/2/2003 3:33:34 AM

.htaccess and crypt
2/27/2003 1:30:21 PM

[announce] CuteSITE CMS
2/24/2003 5:40:00 PM

Question about how to use pfsockopen()
2/24/2003 2:42:58 AM

PHP not supporting method overloading
2/23/2003 12:14:10 PM

removing html attributes by preg_replace
2/17/2003 1:44:52 PM

class extends - need explanation to php class and declaration order behaviour Reply

Group: php.lang Subscribe Posted:8/6/2003 9:02:32 AM Replies:0 Views:16 Items(0)
I know the manual says that classes must be declared before being invoked,
but this works

--- snippet 1 start ---
$obj = new Class1();

class Class1
{
Class1() {
}
}
--- snippet 1 end ---


Now, say I do this:

--- snippet 2 start ---
require_once("class2.php"); // say, this is class 2, which looks like
snippet 1

$obj = new Class1();

class Class1 extends Class2
{
Class1() {
}
}
--- snippet 2 end ---

this just dies, but

--- snippet 3 start ---
require_once("class2.php"); // say, this is class 2, which looks like
snippet 1

class Class1 extends Class2
{
Class1() {
}
}

$obj = new Class1();
--- snippet 3 end ---

this works (note the order of declaration)

Now, I guess I could write code like snippet 3, or even do:

--- snippet 4 start ---
require_once("class1.php"); // just being retentive
require_once("class2.php"); // and again
$obj = new Class1();
--- snippet 4 end ---

and that would work, but can someone explain this behaviour to me?

I thought php pre-parsed and pre-compiled before it begins going through the
code?

And why would it work in a simple case, but not with extends?

thanks

sek...@connectingspace.com ("Sek-Mun Wong")
8/6/2003 9:02:32 AM





Reply:
| or Email(not shown): Name: | Register | Login

Alert me when someone responds to this posting.











Newest Articles

note 97095 added to soapclient.soapclient
4/1/2010 5:58:19 AM

note 97094 added to function.sqlite-changes
4/1/2010 5:06:46 AM

note 97093 added to function.sqlite-changes
4/1/2010 5:06:21 AM

note 97092 added to ref.xmlrpc
4/1/2010 4:52:18 AM

note 97091 added to function.var-export
4/1/2010 3:32:03 AM