News Feed
Jobs Feed
Sections




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

Jani Hartikainen's Blog:
Closures coming in PHP 5.3 and that's a Good Thing
February 20, 2009 @ 14:05:56

Jani Hartikainen takes a look at closures in a new post to his blog - why their good and why they can help you more than you know.

PHP 5.3 will be introducing closures to PHP. Closures, also known as anonymous functions, will allow you to declare functions "inline" and store them in variables. While the syntax may seem a bit weird compared to how it is in languages like JavaScript, closures will be a useful addition to the language. However, like reflection, it's a feature that may not immediately show it's usefulness...

He explains what they are (a sort of anonymous function) and a simple example of them in use - a function that works with data from an array to display each of the rows with the given "formatter" function. Another brief example is a method of using them in PHP functions like array_map and usort as an argument for the callback parameter.

0 comments voice your opinion now!
closure php5 good anonymous function example row loop callback


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Accessing DB2 Data Inside of i5/OS

Zend: Zend Further Expands Its Line of PHP Training Courses

Paul van Iterson's Blog: Why you want Object Oriented Programming in PHP

Zend Developer Zone: Migrating applications from PHP 4 to Zend Core 2.5 w/support for IBM Informix

Timothy Boronczyk's Blog: Anonymous Functions and Closures


Community Events











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


example hack symfony2 performance introduction unittest security install database release package project podcast framework hhvm application facebook composer language component

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