Colon after method declaration?

后端 未结 2 1928
别那么骄傲
别那么骄傲 2020-12-01 15:53
public function getRecords(int $id): array;

Hi, can someone tell me what colon is doing here, in this method declaration inside PHP interface? Is t

2条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 16:26

    Yes it's new syntax introduced in PHP 7 to declare the method returns an array.

    http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration

提交回复
热议问题