PHP - New features of PHP 5.5 with Examples

    1) Generators has been added via the yield keyword.

    Generators provide an easy way to implement simple iterators.For Example:

    function xrange($start, $limit, $step = 1) {

        for ($i = $start; $i <= $limit; $i += $step) {

            yield $i;




      echo 'List of odd Numbers:';


      foreach (xrange(1, 9, 2) as $number) {

          echo "$number ";



    PHP - Check if string contains specific words

    strpos: Find the position of the first occurrence of a substring in a string.

    strpos have 3 parameter and are following: 

    1. haystack:The string to search in.

    2. needle:If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

    3. offset: It is optional, If provided then search will start this number of characters counted from the beginning of the string.

    The offset cannot be negative.

    Subscribe to this RSS feed

    Hot Offer

    Advertise HERE