[wp-hackers] Why pass by reference?
Micky Hulse
mickyhulse.lists at gmail.com
Fri Jul 12 19:59:59 UTC 2013
Hello,
For the second example:
<http://codex.wordpress.org/Function_Reference/add_meta_box#Example>
Why pass $this by reference? Specifically:
array(
&$this,
'render_meta_box_content',
),
Occasionally, I'll see WP example code (like above) where the author
passes $this by reference.
Other examples, like:
<http://codex.wordpress.org/Function_Reference/add_action#Using_add_action_with_a_class>
... $this isn't passed by reference.
Sorry if this is a dumb question, but (within the context of coding
OOP for WP) how do I determine if I need to pass $this by reference?
Is there a good WP/PHP rule of thumb?
For the add_meta_box() example, I don't see any obvious reasons why
passing by reference is required and/or better than not. :D
Thanks!
M
More information about the wp-hackers
mailing list