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

Lorna Mitchell:
Simplest PHP Generator Example
May 23, 2013 @ 10:31:02

On her blog Lorna Mitchell has posted an example of a basic generator written in PHP, a feature of the upcoming PHP version 5.5.

I really like the generators feature that's arriving in PHP 5.5, and since we're now into release candidate releases, it's actually not that far away. I've been speaking on this topic and I thought I'd share my trivially simple code example from my slides.

She includes an example of a very basic generator using the new "yield" keyword and how to implement it in a simple foreach loop. There's also a little talk about when is a good time to use generators in your applications (two examples: complex number calculation and working with large data sets a chunk at a time). For more information on how these generators will work, check out this page in the PHP manual.

0 comments voice your opinion now!
generator simple example introduction manual

Link: http://www.lornajane.net/posts/2013/simplest-php-generator-example

blog comments powered by Disqus

Similar Posts

LoLoCoJr BLog: Rewriting a (large) PHP application to Rails, part 1

Builder.com.au: How do I...recursively scan directories with PHP's DirectoryIterators?

Jaisen Mathai's Blog: How to host the php.net manual on your laptop for offline use

MaltBlue.com: Using ZFTool for Basic Project Management

JavaWorld: Web-less PHP: Command Line PHP


Community Events











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


composer application example code facebook package hhvm hack install security opinion unittest podcast introduction release symfony2 language overview component framework

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