php函数名后冒号(:)+数据类型(返回值类型限制/php新特性)

在PHP7,一个新的功能,返回类型声明已被引入。返回类型声明指定的一个函数返回值的类型。

  • int
  • float
  • bool
  • string
  • interfaces
  • array
  • callable
  • 对象实例

such as:

hasRole方法的返回值必须是布尔数据类型。

原文地址:https://www.cnblogs.com/Ronnie-97/p/12717611.html