[wp-hackers] Class function in Hook

Austin Matzko if.website at gmail.com
Sat Aug 15 23:35:40 UTC 2009

On Sat, Aug 15, 2009 at 6:23 PM, John Kolbert<list at johnkolbert.com> wrote:
> This question may just show a lack of PHP knowledge, but I was wondering
> what the difference between these two were:
> // First
>        $bf_vendor = new bf_vendor();
>        register_activation_hook(__FILE__, array(&$bf_vendor,
> 'installTable'));
> // Second
>        register_activation_hook(__FILE__, array('bf_vendor',
> 'installTable'));

The second makes installTable a static method of bf_vendor, so it will
work as long as installTable can be a static method (which it can't,
e.g., if it references $this).

More information about the wp-hackers mailing list