5 New Features in PHP 7

5 New Features in PHP 7

1. SPEED!

Benchmarks for PHP 7 consistently show speeds twice as fast as PHP 5.6 and many times even faster!

2. Type Declarations

(1)

function enroll(Student student, arrayclasses) {

foreach (classes asclass) {

echo "Enrolling " . student->name . " in " .class;

}

}

(2)

function getTotal(float a, floatb) : int {

   return $a + $b;

}

3. Error Handling

New Hierarchy,Throwable Interface,Type Errors,Type Errors

4. New Operators

(1) Spaceship Operator <=>

$compare = 2 <=> 1

2 < 1 ? return -1

2 = 1 ? return 0

2 > 1 ? return 1

(2) Null Coalesce Operator ??

name =firstName ?? username ??placeholder ?? “Guest”;

The important thing is that it will not raise a notice if the left operand is a non-existent variable.

5. Easy User-land CSPRNG

**What is Easy User-land CSPRNG? **

User-land refers to an application space that is external to the kernel and is protected by privilege separation, API for an easy to use and reliable Cryptographically Secure PseudoRandom Number Generator in PHP.

Get Involved

It’s an exciting time to be involved with PHP! Not only for the language itself, but also the community. If you haven’t jumped on board with the PHP community yet, I’d encourage you to start today.

  1. Find your local users group: http://php.ug

  2. WordPress http://wordpress.meetup.com/

  3. Drupal https://groups.drupal.org/

  4. NomadPHP http://nomadphp.com

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容