Miracle Studios Digital Agency

10 years Experience, Over 1000+ projects Completed. Do it right, the first time.

Visit Website

A new PHP version has been launched, PHP 5.5. If you are still wondering what it is and why it should matter to you, then this article will introduce you to its new features and how it is different from the earlier versions.

Password Hashing

Although it is a quite common and highly simple action being used on internet, still only a few are aware of the right ways to hash and store passwords. The new features included in PHP introduce us to the right methods, along with keeping it updated along with technological advancements. Currently it is using bcrypt and the password can be hashed by using a function, known as password_hash():


  1. password_hash(“topsecret”, PASSWORD_DEFAULT)


It will help to create a hash that involves entire information required for repeating the hash, however not for recovering the password. you can use this function, password_verify() for comparing the value used for creating the current hash with some other password submission.

  1. $hash = “$2y$10$cqcHCw42IE9N.GABOeSkEuQSDF3iKVKIsLljpVqwq0TEc5AJ6Gr3G”;
  2. $matching = password_verify(“topsecret”, $hash);

Here you are required to just compare the version of password, which has been already submitted, with hash generated in previous example, without requiring much effort. This is even more convenient if it is back ported for any older PHP version (5.3+) incorporated in PHP, thus making it easier and faster for you to implement it in the current projects.

People who have worked on other languages, like Python, they might be already familiar with this feature. It’s not new, but definitely recent in PHP. Being special function, a generator makes use of yield statements, instead of single return. When you foreach the generator, it acts as an iterator, returning a latest value on every iteration. it will be clearer with this example:

  1. function moves() {
  2. yield “hop”;
  3. yield “skip”;
  4. yield “jump”;
  5. }

It might appear as normal function; however it acts as a generator with yield statements and can be sued like this:


  1. foreach (moves() as $m) {
  2. echo “he does a ” . $m;
  3. }

Other generators perform much more intricate tasks, such as calculating values, but it will definitely give you an idea of the functions of this feature. It can prove to be quite useful, as using generator eliminates the need to have a huge data structure being generated with the help of range ().


The exceptions were introduced in PHP with the launch of PHP 5.0 and it is being used by a large number of latest applications. However, PHP 5.5 bring along another extension of this function with finally clause. It might not be new for many, who have already seen it in another language, particularly Java. Finally clause can be run by adding it to the try/catch statements. Take for example:


  1. try {
  2. $myFile = fopen(“textfile.txt”, “w+”);
  3. // do impressive and complicated things here
  4. } catch (Exception $e) {
  5. echo “Stuff went wrong: ” $e->getMessage();


  1. } finally {
  2. // either way, close the file
  3. fclose($myFile);
  4. }

In this example try/catch has been wrapped around a code, which might give away an exception, preferably at try block. In case it gives away an exception by code in try block, then catch block needs to be entered right away. PHP 5.5 brings along finally block which can be run after any one of these. In the mentioned example, resource handle is closed irrespective of the code’s outcome.

APC, OPcache and Zend Optimizer

APC, a PHP opcode cache, developed some issues in PHP 5.4. It was already installed by numerous production systems, while the launch of PHP 5.4 was delayed. PHP being an interpreted language, which we do not compile, requires opcode cache. To use it a code is written and when it is run, it is parsed by the interpreter, who turns this into opcode, later in machine code. As PHP script is used multiple times without making any changes, thus opcodes can be cached and this is the function of opcode cache.

The existing product Zend Optimizer has been donated by Zend for PHP 5.5. It now forms a part of the PHP’s core and is known as OPcache. The latest and all the coming PHP versions will include opcode cache as these two will be always released together.

Upgrading to PHP 5.5

Steps involved while upgrading to latest PHP versions are quite simple and these will be a delightful surprise if you have already upgraded applications like between PHP 4 and 5. Here are some key points listed to make migration easier.


  • Enabling E_DEPREACATED, an error reporting level, will highlight any features which are in use but are not available in latest or next version.


  • PHP 5.4+ has a built in standalone web server. This might not be used in live environment, however it is a great option to know if your code will be effective or not. So get your hands on the newest PHP version, compile it and use web server for carrying out some testing.


  • Testing and development platforms should be upgraded first, followed by staging, before you begin to apply PHP 5.5 version to live server. as plenty of applications are already running in virtualised environment, setting up new platform and deploying it might be easier, and then you can switch to it if everything is working well.

The latest versions of PHP language are quite different from the earlier versions and a target has been set to make a major launch every year, as launch date of PHP 5.4 was March 2012, while PHP 5.5 was released during June 2013. It is clear by looking at this scenario that rather than waiting for a big release, PHP programmers can access better features and other useful content at a convenient duration. However, it also means that PHP programmers will be required to upgrade their platforms more frequently than they were doing till now.

Miracle Studios Digital Agency

10 years Experience, Over 1000+ projects Completed. Do it right, the first time.

Visit Website
There are no comments.

Leave a Reply