[wp-hackers] Passing class methods by reference

Dan Gayle dangayle at gmail.com
Wed Aug 4 16:06:48 UTC 2010

I see some plugins that have a callback to a class method by reference like so:

array( &$this, 'function_name' ));

The codex says "if the function is a member of a class within the
plugin it should be referenced as array( $this, 'function_name' )"

I assume that passing a reference is an attempt to save memory, but in
PHP 5 aren't objects automatically passed by reference? What is the
benefit, if any, of this style of callback?

More information about the wp-hackers mailing list