-
Website
http://www.wp-fun.co.uk -
Original page
http://www.wp-fun.co.uk/2007/11/08/using-objects-for-wordpress-plugins/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
Improving The Web
5 comments · 1 points
-
michaeltwofish
6 comments · 12 points
-
Busby SEO Test
2 comments · 1 points
-
ringmaster
7 comments · 1 points
-
SE7EN (Nice from Thailand)
4 comments · 1 points
-
-
Popular Threads
ie.
class myClass(){
function __construct(){
// do something
}
function myClass($args){
//php 4 compliant fake constructor
$args = func_get_args();
call_user_func_array(array(&$this, '__construct'), $args);
}
Is there a benefit to using call_user_function over simply calling myClass from within the __construct method?
But I don't know if there are some valid reasons to not use __contruct($args) { $this->myClass($args) ); as you suggest.
Btw, I've studied a little more and I've discovered that
however, IMHO, this should not be used. Especially if you work with object that extends other object. Because it should be very easy to break your code simply changing the name of the parent class [parent::MyParent ==> parent::NewParentName ].
I guess it really is a case of deciding how long the plugin is likely to be around, and whether you want to support it later in its life to upgrade to PHP 6.
Having said that many hosts are only now getting up to PHP 5. If PHP 6 won't be backward compatible then I guess you need to wonder how long it will really be until PHP 6 is offered. We could be facing up to 5 years before it becomes well supported.
That's a long time for a plugin.
That caveat aside, this is a nice little site you've got here. I'll subscribe once you change the title ;-)
Keep up the good work.
Class wp_something {
...
}
new wp_something;
because, actually, I only need to run the constructor of the class - I do not need a variable storing the created object ;)