Overview of PHP 7

1. What are the new features in PHP 7?

While migrating from PHP 5.6 to PHP 7, all PHP developers are so excited to know what are the new features in PHP 7. Well, PHP 7 does not disappoint anyone, here are some of the interesting new features applied in the new version.  


High performance & Consistent 64-bit support

This is the best feature that PHP 7 provides. While comparing to PHP 5.6 and HHVM 3.7, PHP7 is absolutely very fast in performance. It also provides high performance while using with frameworks and Content Management Systems(CMS).

Scalar type declaration

Scalar type declaration allows us to declare the function parameters and return the values with required data type. The return type can be any one from integer(int), string(string), floating point number(float) and boolean(bool) types.  

Return type declaration

Return type declaration specifies the data type of return value from a function, it is similar to argument type declaration.  

Null Coalesce operator

Null Coalesce operator ?? combines isset() and assignment of value, first it checks whether the variable exists or not, if it does then it takes the value, if not variable will be assigned with the second operand value. It is an interesting operator which decreases the time and long codes. 
$email =  $_GET['email' ??  'no email';



Spaceship operator

Spaceship operator <==> is used to compare two variables, it returns three values, 
-1 (less than)
 0 (equal to)
 1 (greater than)
It works with integer, floating point number and string also. 



<?php
echo <=> 1// 0
echo <=> 2// -1
echo <=> 1// 1
?>

Constant array

Constant array can be defined using define().

<?php
define
('Names', [
    
'Peter',
    
'Harry',
    
'Mary']);

echo 
Names[1]; // outputs "Harry"?>

Anonymous class

The concept of anonymous class is declaring a class within another class. For detailed information about anonymous class just visit here.

2. Why not PHP 6?

It's not like what we all think about, PHP 6 already existed and it was completely different from the new release. PHP 6 is kind of failure as it takes lot of CPU time and memory since it uses UTF-16 as default encoding.

Version 6 is failure, like PHP 6 is failure; Perl 6 is failure; MySQL 6 existed but have not been released, so this might have been a consideration.

PHP 6 project and it's features were widely known, and the current release is entirely different from that, so people would definitely be confused. This is one reason why they skipped version 6.






Jefinson O

I'm a PHP developer, I'm so interested to share something with people what I learn today. Blogging is my Hobby and I love doing it. Google

2 comments:

  1. its a useful blog i was useful to learn thank u jef

    ReplyDelete
    Replies
    1. I am looking forward to bring more about PHP 7. Thank You.

      Delete