PHP7新特性

php7.0新特性:

https://www.php.net/manual/zh/migration70.new-features.php

1、强类型转换:

  declare(strict_types=1)必须是文件的第一个语句。如果这个语句出现在文件的其他地方,将会产生一个编译错误,块模式是被明确禁止的。

类似于encoding指令,但不同于ticks指令,strict_types指令只影响指定使用的文件,不会影响被它包含(通过include等方式)进来的其他文件。该指令在运行时编译,不能修改。它的运作方式,是在opcode中设置一个标志位,让函数调用和返回类型检查符合类型约束。

见链接:https://blog.csdn.net/beyond__devil/article/details/52584082

2、void类型

   Type declarations for parameters and return values can now be marked as nullable by prefixing the type name with a question mark. This signifies that as well as the specified type, NULL can be passed as an argument, or returned as a value, respectively.

    可以返回空值 比如null 

   https://www.php.net/manual/en/migration71.new-features.php

3、数据类型中的?

    表示 参数是指定的类型或者为 NULL  

    参数定义参考:

     https://www.php.net/manual/zh/functions.arguments.php#functions.arguments.type-declaration

原文地址:https://www.cnblogs.com/cbugs/p/12195451.html