Monday, 22 June 2015

How to Upgrade PHP 5.3 to PHP 5.4 in WAMP Server in window 7


Adding addons  PHP 5.4 in WAMP Server is quite easy, just you need to follow the following (Works for me).

Please take the backup of code and database before Start.

Please make the backup of php.ini files. When we add addons in wamp server then, we can access the new PHP (php5.4) and old php (php5.x). Both are easily accessible.

Just to need to change the PHP Version like Below:

How to Upgrade PHP 5.3 to PHP 5.4 in WAMP Server in window 7

Let Suppose following:
1) Addin 5.4.42
2) Wamp Server drive is E:


Follow the following steps to upgrade your PHP version.

  1. Download PHP5.4 From http://windows.php.net/download/#php-5.4 (Download Thread Safe)
  2. Go to PHP Folder Location (i.e E:\wamp\bin\php)
  3. Create a new folder with name php5.4.42.
  4. Extract the download files and save in E:\wamp\bin\php\php5.4.42.
  5. Copy the following files from your old PHP directory to your new PHP directory ().
        php.ini
        phpForApache.ini
        wampserver.conf
    
  6. Open new copied php.ini file.
  7. Update the extension_dir path in file.
  8. Open new phpForApache.ini file.
  9. Update the extension_dir path in file.
  10. Reboot your system.
  11. Start wamp Server
  12. Go to wampserver =>PHP=>Version=>PHP 5.4.42
  13. Now running PHP5.4.42
    Note: you might need to Re-enable the PHP extension like CURL, Openssl etc

Saturday, 20 June 2015

New features of PHP 5.5 with Examples


New features of PHP 5.5 with Examples


Following are 5.5 new features.

  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 ";
      }
      
  2. finally: keyword added in try catch.
    In try catch, finally block will be called every time, regardless of whether an exception has been thrown or not.
    For Example:
        
        try {
        //write code here 
      }
      catch (Exception $e) {
          //Exception comes here
      }
      finally {
          echo "I am called everytime";
      } 
  3. New password hashing API
    Password hashing API that makes it easier to securely hash and manage passwords using the same crypt() in PHP has been added.
  4. foreach now supports list()
    Now in PHP5.5, You can use list function inside foreach function.
    See Example
     $listArray = [
        [10, 20],
        [30, 40],
        [50, 60],
    ];
    
    foreach($listArray as list($a, $b)) {
        echo "A: $a; B: $b";
    } 
  5. empty() supports expressions
    Now you can use expression in empty function.
    For Example:
      if(!empty(2*3)){
        echo "Its working";
        }
  6. Array and String literal dereferencing.
    String and Array can now be dereferenced directly to access individual elements OR characters.
    For Example
    echo 'Array dereferencing: ';
      echo [10, 02, 30][0];//10
      echo "\n";
      
      echo 'String dereferencing: ';
      echo 'Web Technology'[0]; //W
        
  7. Class name resolution via ::class
    ClassName::class to get a fully qualified name of class ClassName.
    For Example
    namespace Foo;
      class Bar {}
       
      echo Bar::class;
  8. OPcache extension added
    The Zend Optimiser+ opcode cache has been added to PHP5.5 as the new OPcache extension.
  9. foreach now supports non-scalar keys. For non-scalar keys, an Iterator must be used as they cannot occur in native PHP array.
  10. Apache 2.4 handler supported on Windows
  11. Improvements to GD Library.