[wp-hackers] Class function in Hook

John Kolbert list at johnkolbert.com
Sat Aug 15 23:49:11 UTC 2009


Thanks everyone for the responses and especially for included links.  
Some of this gets hard to wrap your head around so I appreciate the  
references.

-John

John Kolbert
http://www.johnkolbert.com/

On Aug 15, 2009, at 6:39 PM, Mike O'Malley wrote:

> On Sat, Aug 15, 2009 at 7:23 PM, John Kolbert <list at johnkolbert.com>  
> wrote:
>
>>
>> // First
>>       $bf_vendor = new bf_vendor();
>>
>>       register_activation_hook(__FILE__, array(&$bf_vendor,
>> 'installTable'));
>
>
> In the first, $bf_vendor is an instance of the class bf_vendor();  
> $bf_vendor
> has it's own copy of any non-static member variables that are  
> defined in the
> class, and the method installTable() should probably only operate on  
> those.
>
> This loosely translates to: $bf_vendor->installTable();
>
>
>
>> // Second
>>
>>       register_activation_hook(__FILE__, array('bf_vendor',
>> 'installTable'));
>>
>>
> In the second, you are registering installTable to be called as a  
> static
> method of the class bf_vendor. This loosely translates to:
>
> bf_vendor::installTable();
>
>
>> Both of these methods seemed to work. I was just wondering if there  
>> is any
>> difference or preferred method between the two. Thanks guys.
>
>
> If that is the case, you most likely don't have any non-instance  
> member
> variables of the class bf_vendor(). Which versions of php and which
> configurations of php.ini support referencing static members/methods  
> as
> instance members/methods currently escapes me, but in general, it  
> should be
> avoided.
>
> For more information:
>
> http://us2.php.net/manual/en/language.oop5.static.php
> and
> http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback
>
> --
> Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list