|
||||||||||
|
New in This Group Session hanling & and disable disabled3/8/2003 6:50:26 AM Text>Image3/8/2003 2:46:54 AM Apache being mean to sessions?3/5/2003 4:52:58 PM num string format3/2/2003 10:15:42 PM General Speed and Server Caching3/2/2003 3:33:34 AM .htaccess and crypt2/27/2003 1:30:21 PM [announce] CuteSITE CMS2/24/2003 5:40:00 PM Question about how to use pfsockopen()2/24/2003 2:42:58 AM PHP not supporting method overloading2/23/2003 12:14:10 PM removing html attributes by preg_replace2/17/2003 1:44:52 PM |
class extends - need explanation to php class and declaration order behaviour
|
|||||||||
| 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 |
note 97095 added to soapclient.soapclient
note 97094 added to function.sqlite-changes
note 97093 added to function.sqlite-changes
note 97092 added to ref.xmlrpc
note 97091 added to function.var-export