Callback functions in PHP

What is a PHP callback function?

A callback (callable) function in PHP is one which is being passed as another function’s parameter—by its name as a string. Callback functions can not only be simple functions, but also object methods, including static class methods.

See the PHP manual post about this.

A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1.

Static class methods can also be passed without instantiating an object of that class by passing the class name instead of an object at index 0. As of PHP 5.2.3, it is also possible to pass 'ClassName::methodName'.


About samehramzylabib

See About on
This entry was posted in PHP Code Snippets, PHP Data Value Types, PHP Language Constructs, PHP Object Oriented Programming, PHP Script Writing. Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s