Callback functions

Callback functions are called by PHP whenever a certain event happens. For example, when parsing XML, PHP can call a function every time it hits a tag, and you can define your own user function for the purpose of being called by PHP, then pass the name of the function to PHP. Callback functions invariably have strict requirements on the number of parameters they can take, as very often PHP will want to pass variables to your callback function for you to use.

We'll be covering individual cases of callback functions as required throughout this book - for now it is simply necessary that you understand what they are.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: The declare() function and ticks >>

Previous chapter: Variable functions

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.