[PHP] parent constructor
Hey guys just a general question... if you have a parent::__constructor() call in your constructor function, should that call ideally be placed before or after the code inside the current constructor? or it doesnt really matter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parent constructor
SLaVKa wrote: Hey guys just a general question... if you have a parent::__constructor() call in your constructor function, should that call ideally be placed before or after the code inside the current constructor? or it doesnt really matter That depends on which code you want to run first. Seriously. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parent constructor
Jasper Bryant-Greene wrote: SLaVKa wrote: Hey guys just a general question... if you have a parent::__constructor() call in your constructor function, should that call ideally be placed before or after the code inside the current constructor? or it doesnt really matter That depends on which code you want to run first. Seriously. true in practice but in theory the parent ctor should be called first before anything else is done - the theory is that the 'base of the object' should be completely setup before you construct stuff in the current level (which may rely on stuff that is configured/setup in the parent ctor). so, what Jasper said, basically. NB: it's parent::__construct() not parent::__constructor() Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parent:: constructor
Hi, Can anyone point me to a good explanation of how the parent:: constructor works? I've tried searching the php site for it with no success. I've been given a set of code to work on, but am getting the error: Fatal error: Undefined class name 'parent' for one section of it. cheers. James. -- James Stewart http://www.britlinks.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parent constructor
On Wednesday 07 February 2001 05:14, Aaron Tuller wrote: ok, I == dumb. this works: $parentClass = get_parent_class($this); eval("$parentClass::$parentClass();"); still, I think I should be able to do what I wrote below. Um, you know the name of your parent class, so why do you use get_parent_class() at all? -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "Software is like sex: the best is for free" -- Linus Torvalds -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parent constructor
At 12:13 PM +0100 2/7/01, Christian Reiniger wrote: On Wednesday 07 February 2001 05:14, Aaron Tuller wrote: $parentClass = get_parent_class($this); eval("$parentClass::$parentClass();"); still, I think I should be able to do what I wrote below. Um, you know the name of your parent class, so why do you use get_parent_class() at all? so that way I can have a general purpose way of calling a parent constructor like "super()" or whatever. It seems silly to hardcode the name of my parent class into the code of the class besides in the "extends" part in the definition. that way if I change the hierarchy, I don't have to worry about changing the constructor, it just always points to the parent. sorry if that isn't clear. -aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parent constructor
Try 'parent::' On Wed, 7 Feb 2001, Aaron Tuller wrote: At 12:13 PM +0100 2/7/01, Christian Reiniger wrote: On Wednesday 07 February 2001 05:14, Aaron Tuller wrote: $parentClass = get_parent_class($this); eval("$parentClass::$parentClass();"); still, I think I should be able to do what I wrote below. Um, you know the name of your parent class, so why do you use get_parent_class() at all? so that way I can have a general purpose way of calling a parent constructor like "super()" or whatever. It seems silly to hardcode the name of my parent class into the code of the class besides in the "extends" part in the definition. that way if I change the hierarchy, I don't have to worry about changing the constructor, it just always points to the parent. sorry if that isn't clear. -aaron -- John Donagher Application Engineer Intacct Corp. - Powerful Accounting on the Web 408-395-0989 720 University Ave. Los Gatos CA 95032 www.intacct.com Public key available off http://www.keyserver.net Key fingerprint = 4024 DF50 56EE 19A3 258A D628 22DE AD56 EEBE 8DDD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] parent constructor
why doesn't this work? $parentClass = get_parent_class($this); parent::{$parentClass}(); I get a parse error. can I not use variable functions with the "::" syntax? I tried eval() and it loses the context. thanks for the help! -aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parent constructor
ok, I == dumb. this works: $parentClass = get_parent_class($this); eval("$parentClass::$parentClass();"); still, I think I should be able to do what I wrote below. -aaron At 8:05 PM -0800 2/6/01, Aaron Tuller wrote: why doesn't this work? $parentClass = get_parent_class($this); parent::{$parentClass}(); I get a parse error. can I not use variable functions with the "::" syntax? I tried eval() and it loses the context. thanks for the help! -aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]