Php 5.5

  • 208 views
Uploaded on

New features in php 5.5

New features in php 5.5

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
208
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
15
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. PHP 5.5 Whats New!! Presented By : Naseer Ahmad
  • 2. Performance and Memory Performance by 10-30% Memory by 50% ● ● precompiled script bytecode in shared memory reduction in loading and parsing of scripts on every request HOW??? !! Zend Optimizer & opcode cache !! Available in PECL for PHP versions 5.2, 5.3 and 5.4
  • 3. New Features ● Finally keyword. ● foreach supporting lists now. <?php $array = [ [1, 2], [3, 4], ]; foreach ($array as list($a, $b)) { echo "A: $a; B: $bn"; } ?>
  • 4. New Features ● empty() supports arbitrary expression. ● Class name resolution via ::class <?php namespace NameSpace; class ClassName {} echo ClassName::class; //NameSpaceClassName ?>
  • 5. New Features(Array & String Direct Referencing) <?php echo 'Array dereferencing: '; echo [1, 2, 3][0]; Print : Array dereferencing : 1 echo "n"; echo 'String dereferencing: '; echo 'PHP'[0]; echo "n"; ?> Print : String dereferencing: P
  • 6. New Features(Generators) ● ● ● ● Routine to control the iteration of a loop Sequence of values in loop Values on demand In simple words, put foreach over a function :)
  • 7. New Features(Generators) Fine for normal usage What if we want to abstract it?
  • 8. Generators
  • 9. New Features(Generators) Simpler, lesser code
  • 10. New Features(Password Hashing Api) > Php 5.5 Relying on ● custom hash methods ● somewhat confusing crypt() method Php 5.5 Hashing api, wrapper around crypt() No external libraries,no additional installation PASSWORD_BCRYPT hashing algorithm, 60 characters hash. Salt and Cost options.
  • 11. <?php $timeTarget = 0.2; $cost = 9; do { $cost++; $start = microtime(true); password_hash("test", PASSWORD_BCRYPT, ["cost" => $cost]); $end = microtime(true); } while (($end - $start) < $timeTarget); echo "Appropriate Cost Found: " . $cost; //Appropriate Cost Found: 11 ?>
  • 12. New Features(Password Hashing Api) ● password_get_info — Returns information about the given hash ● password_hash — Creates a password hash ● password_needs_rehash — Checks if the given hash matches the given options ● password_verify — Verifies that a password matches a hash
  • 13. New Features(Password Hashing Api) <?php $hash = password_hash(‘MyPassword’, PASSWORD_DEFAULT); if(password_verify(‘MyPassword’, $hash)){ echo “Password is valid!!”; } else{ echo “invalid password.”} ?>
  • 14. References http://be1.php.net/migration55.new-features http://www.sitepoint.com/generators-in-php/ http://geekmonkey.org/articles/39-php-5-5-generators http://blog.ircmaxell.com/2012/07/what-generators-can-do-for-you.html http://blog.asmallorange.com/2013/08/php-roadmap-performance/ http://php.net/manual/en/function.password-hash.php http://uk1.php.net/manual/en/book.opcache.php https://support.cloud.engineyard.com/entries/26902267-PHP-Performance-IEverything-You-Need-to-Know-About-OpCode-Caches