Why do you need to wrap a function inside array($this, function)

It’s a PHP callback. You need the syntax to keep a reference to the class instance.

Put it this way – if you didn’t have $this, how does the caller know that getStuffDone is a method of your class, and not just a regular PHP function? It doesn’t.

Using array( $this, 'getStuffDone' ) says to PHP:

Hey bro, you need to call the method getStuffDone on this instance of my class

Leave a Comment