News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

phpRiot.com:
Using Callback Functions in PHP
November 19, 2010 @ 09:50:35

On phpRiot.com today there's a new tutorial posted by Quentin Zervaas showing you how to use the callback functions in PHP (with examples using call_user_func).

A commonly used technique when programming is to use callbacks. A callback is a piece of code that is passed to a function that is later executed by that function. In this article I will show you how to define and call callbacks in PHP, as well as a practical example of how callbacks can be useful.

He starts with a normal script flow that has to wait until everything's done in order to handle the results. He then compares this to using a callback method that can be executed during each iteration of the script, reducing the amount of processing that has to be done after the fact. Code snippets are included of an example that pulls from a remote RSS feed and loops through the results.

0 comments voice your opinion now!
callback tutorial function example


blog comments powered by Disqus

Similar Posts

DevShed: Working with Multiple Template Files to Separate Logic from Presentation (Part 3)

PHPMaster.com: Generate QR Codes in PHP

PHPMac.com: Building and Installing Apache 2.2.2 and PHP 5.1.3 (or 5.1.4) on Mac OS X 10.4.6

DevShed: Implementing Property Overloading in PHP 4

Developer Drive: PHP User Survey: Setting Variable Values and Reading from Tables


Community Events





Don't see your event here?
Let us know!


framework install interview symfony2 experience list series developer opinion testing unittest release language code threedevsandamaybe refactor podcast introduction community laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework