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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容