What’s New in PHP 5.5

Canvas Code

PHP 5.5 was recently released, introducing several exciting new features to the language. In this article, we’ll go through some of the most interesting additions and discuss the benefits they provide to developers.

Generators

Generators are one of the most eagerly anticipated new features. They provide a way to handle iteration without having to write a class that implements the Iterator interface. Making a class conform to the Iterator interface requires a substantial amount of boilerplate code, so being able to avoid this by using generators can significantly reduce the size and complexity of code that developers must write.

Generators derive their functionality from the new yield keyword. A generator looks very similar to a normal function, but instead of returning a single value, a generator may yield any number of values.

To properly illustrate the power of generators, an example is needed. Consider PHP’s range() function, which returns an…

Ver la entrada original 1.236 palabras más

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s