Posts

Showing posts from January, 2016

What has changed in PHP 5.5.x

1.Generators added   Support for generators has been added via the yield keyword. Generators provide an easy way to implement simple iterators without the overhead or complexity of implementing a class that implements the Iterator interface. A simple example that reimplements the range() function as a generator (at least for positive step values): <?php function  xrange ( $start ,  $limit ,  $step  =  1 ) {     for ( $i  =  $start ;  $i  <=  $limit ;  $i  +=  $step ) {          yield $i ;     } } echo  'Single digit odd numbers: ' ; /*  * Note that an array is never created or returned,  * which saves memory.  */ foreach ( xrange ( 1 ,  9 ,  2 ) as  $number ) {     echo  " $number  " ; } echo  "\n" ; ?> The above example will output: Single digit odd numbers: 1 3 5 7 9      2. finally keyword added try - catch blocks now support a finally block for code that should be