Your SlideShare is downloading. ×
What is new in PHP 5.5 - HuyenNT
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

What is new in PHP 5.5 - HuyenNT


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. What's new in php 5.5 By: Nguyen Thi Huyen-framgia
  • 2. 1. Installation. 2. New features & demo. 3. References.
  • 3. 1. Installation. - Access website download “LAMP Stack Dev 5.5.1-0 (64 bit)”. - Install “./bitnami-lampstack-5.5.1-0-dev-linux-x64-” in terminal.
  • 4. 2. New features & demo. a) 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. - 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.
  • 5. b) Finally. PHP 5.5 adds support for the finally keyword. finally allows developers to specify code to be run at the end of try and catch blocks, regardless of whether an exception was thrown or not, before the normal execution flow resumes. - If you use “finally”, you won use “catch”: //without catch function example() { try { //do something that throws an exeption } finally { //this code will be executed even when the exception is executed } }
  • 6. - Code within the FINALLY block will be executed even if the “return” is called inner try/catch block. - Code within the FINALLY block will be executed even if haven't any matching catch block.
  • 7. c) Array and String Literal Dereferencing. - Array and string literals can now be dereferenced using array access syntax: <?php // array dereferencing - returns 3 echo [1, 3, 5, 7][1]; // string dereferencing - returns "l" echo "hello"[3]; ?> - This feature was added primarily to improve the consistency of the language.There are some interesting applications to consider, such as the following: <?php $randomChar = "abcdefg0123456789"[mt_rand(0, 16)]; ?>
  • 8. d) Changes to foreach. The list() construct in PHP allows the values of an array to be easily assigned to variables. It’s now possible to use list() with multidimensional arrays within foreach loops: <?php $data = [ ["sea", "blue"], ["grass", "green"] ]; foreach ($data as list($object, $description)) { echo "The $object is $descriptionn"; } ?> This is a powerful new feature that has the potential to make iterating through nested arrays much easier and cleaner.
  • 9. e) Password Hashing. - The new password hashing API is one of the most important and useful features added in PHP 5.5. In the past, developers have had to rely on the somewhat confusing crypt() function. public function generatePasswordHash($raw_password) { return crypt($raw_password, Randomness::blowfishSalt()); } public function isValidPassword($raw_password) { return crypt($raw_password, $this->password) === $this->password; }
  • 10. - The new API introduces two new functions: password_hash() -Creates a password hash password_verify()-Verifies that a password matches a hash. <?php echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."n"; ?> <?php // See the password_hash() example to see where this came from. $hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq'; if (password_verify('rasmuslerdorf', $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } ?>
  • 11. Moreover: Using empty() with Function Calls and Expressions, Class Name Resolution.
  • 12. 3. References.
  • 13. Thank you for listening !