Sunday 3 July 2016

PHP7 Next Generation Of PHP With PHPNG


php7 w3workers
Next Generation of PHP


Initially PHP started as PHP/FI in 1994 written in c programming language by Rasmus Lerdorf for his personal use.

Later Rasmus recreated PHP with database interaction to use with advance PHP framework in 1995 and released source code open to all developers to modify and reporting bugs.

So basically PHP follows C structure and its variable declaration is similar to Perl syntax for easy adopt by developers who is familiar with C and similar language.


PHP Versions



php generations w3workers
PHP Versions



PHP3: php3 was the first version of PHP release with Object oriented programming support and database connectivity with MySql, PostgreSql by new PHP Development Team in 1998.


PHP4: php3 was not designed to handle complex applications efficiently to make PHP more powerful and capable to work with complex application with high efficiency new PHP engine designed name as Zend Engine.
PHP4 was based on Zend Engine with high security and efficiency to meet complex applications expectation this took nearly two years and then launched in 2000.


PHP5: After further improvements in php4 new version of PHP launched which is later became the most popular version of PHP in 2004 with Zend Engine 2.0


PHP6: PHP developers team was working to change some Unicode binary to make next generation PHP but during development things become complex and another project started with name PHP7 which have features those expected in PHP6 and other new features.
Also many blog post and information related to PHP6 shared by many communities even some authors launched new php books cover page title as PHP6 but later they changed and updated once officially declare that PHP will skip PHP6 and will be launch new version name as PHP7, So no PHP6 exist officially.


PHP7: The latest generation of PHP which is mainly developed to make PHP execution fast, and they successfully achieved twice faster speed then old versions of PHP.
PHP7 is based on new engine name PHPNG  (PHP Next Generation)
HHVM is developed by Facebook team from open source PHP project and become fastest engine. Later PHP team used the similar concept which is used in HHVM and developed New Generation PHP which is more faster than HHVM.

PHP7 is officially launched in 2016 with twice fast speed than old PHP.


PHP7 speed report w3workers
PHP7 is faster than all old PHP versions and some other server side scripts



New Features of PHP7

1) Scalar type declarations

  1. <?php
  2. function addition(int $a, float $b) {
  3. return $a+$b;
  4. }
  5. ?>

2) Return type declarations


  1. <?php
  2. function addition(int $a, float $b) {
  3. return(float) ($a+$b);
  4. }
  5. ?>

3) Null coalescing operator


  1. <?php
  2. $arr = [‘key’=>’value’];
  3. $message = isset($arr[‘key’])?$arr[‘key’]:’not set’;
  4. ?>

4) Spaceship operator

  1. <?php
  2. echo 1 <=> 1; // 0
  3. echo 1.5 <=> 2.5; // -1
  4.  echo "a" <=> "b"; // -1
  5. ?>

5) Constant arrays using define()


  1. <?php
  2. define(‘AREA, [
  3.     ‘triangle’,
  4.     'circle',
  5.     'rectangle'
  6. ]);
  7. echo  AREA [1]; // outputs  "triangle"
  8. ?>

6) Anonymous classes

  1. <?php
  2. $str = new class {
  3. public function str() {
  4. return ‘string’;
  5. }
  6. }
  7. Calling ->  $str->str();
  8. ?>
   
7) Unicode codepoint escape syntax


  1. <?php
  2. echo "\u{0000aa}";
  3. ?>

8) Closure::call()


  1. <?php
  2. class A {private $x = 1;}
  3. $getXCB = function() {return $this->x;};
  4. $getX = $getXCB->bindTo(new A, 'A');
  5. echo $getX();
  6. ?>

9) Filtered unserialize()


  1. <?php
  2. $data = unserialize($foo, ["allowed_classes" => false]);
  3. ?>

10) Group use declarations


  1. <?php
  2. use some\namespace\ClassA;
  3. use function some\namespace\fn_a;
  4. use some\namespace\{ClassA, ClassB, ClassC as C};
  5. ?>

11) Generator Return Expressions


  1. <?php
  2. $gen = (function() {
  3. yield 1;
  4. yield 2;
  5. return 3;
  6. })();
  7. foreach ($gen as $val) {
  8. echo $val, PHP_EOL;
  9. }
  10. echo $gen->getReturn(), PHP_EOL;
  11. ?>

12) Generator delegation


  1. <?php
  2. function gen()
  3. {
  4. yield 1;
  5. yield 2;
  6. yield from gen2();
  7. }
  8. function gen2()
  9. {
  10. yield 3;
  11. yield 4;
  12. }
  13. foreach (gen() as $val)
  14. {
  15. echo $val, PHP_EOL;
  16. }
  17. ?>

13) Integer division with intdiv()



  1. <?php
  2. var_dump(intdiv(10, 3));
  3. ?>

14) preg_replace_callback_array()


The new preg_replace_callback_array() function enables code to be written more cleanly when using the preg_replace_callback() 


PHP CMS WordPress is working properly with New version of PHP7 framework Laravel is also supported all features and function added in new generation of PHP and all other frameworks and CMS are replacing deprecated function by updating library new generation is going to make web experience faster.


Now you can test your web application on PHP7 with WAMP new wamp is available with new APACHE and PHP7 support.




Thanks for reading if you have any question add in comments section.

3 comments:

  1. PHP is a server side scripting language and most of the developer choice is PHP nowadays, since it is highly secure. Your blog on PHP secureness is unique from other. I hope your content was read by most of the people in the World Wide Web.
    Regards:
    PHP Training in Chennai | PHP Course in Chennai

    ReplyDelete