PHP 5.5 is currently in its alpha4 version and due to release in the next couple of months. What can we expect from this latest version of PHP. Imagine building a function which could retain their index and variable states between each runs in the simplest way. Imagine being able to map nested arrays by using a list function without having the need of assigning results to a local variable. Imagine if there is an easy way to send mail through SMTP. How about being able to access individual characters in a string by using index like that of an array and the implementation of the ‘finally’ keyword like that of other web services and programming language. In PHP 5.5 all of these are now being simplified through the use of generators, upgraded list function, exciting SMTP updates via cUrl, string accessibility upgrades and the implementation of the ‘finally’ keyword in the try/catch block.
With the use of generators, developers can now implements simple iterators minus the overhead of implementation complexities attached with it. That is because of the new “yield” command which when encountered by the program will give pause to the function’s execution and still continues to run the rest of the program. When you want to proceed with the functions execution, you can tell the function to continue where it left off, thus preserving the values of local variable defined in that function. It benefits you when you want the local variables to be preserve while continuing to run the rest of the code.
The next big thing about the PHP 5.5 release is the new list function that does not only convert one dimensional array into variable but also two multidimensional arrays as well. In this new list function, you can map out the entire nested arrays into a list variable without using the so called “middle man” variables resulting to cleaner and more readable code. This will significantly decrease your code length and at the same time reducing the coding phase of the developers which in turn increase your productivity in the long run. So, instead of writing something like:
1
2
3
4
|
$data = array ( "John" , "Smith" , "032-234-4923" ); $fName = $data [0]; $lName = $data [1]; $cell = $data [2]; |
You could just write:
1
2
|
$data = array ( "John" , "Smith" , "032-234-4923" ); list( $fName , $lName , $cell ) = $data ; |
In the aspect of cURL, the PHP development team added some new features like the FTP directives, directives to setting cookies, SSL and accounts directives, directives for SMTP and RTSP protocols, and among others. In the past, you will need to change your server’s send mail program for sending mails via SMTP server, or you can use a third party library to make this possible yet both of these are not the best option. But the new cURL directives will enable you to send messages directly to the SMTP server like Gmail with just a short amount of coding.
The new PHP release increases the capability of accessing a string variable by making the string variables work like that of an array. Thus, you can access directly the characters in the string by the use of indexing and assigning it to another variable. These improve the accessibility and simplicity of string variables and make your code more readable. Check this quick sample below.
1
2
|
echo "Hello World" [2]; //this line will echo out 'l' echo [ "john" , "jane" , "james" ][2]; //this echos "james" |
The use of the ‘finally’ keyword in the try/catch block leads to safer and more secure implementation of the try/catch block. By using ‘finally’, the program will be able to have a sure default function to execute if one of the two options is met or if other options fail unexpectedly thus leads to secure coding.
So the PHP 5.5 version is not only made for simplicity but also for code readability, and to maximize the development phase by minimizing the coding time. These are just some of the cool stuff to look out for in PHP 5.5. So be sure to implement this new version when the stable release is out.
Facebook
Twitter
Pinterest
Google+
LinkedIn
Email