方法声明后的冒号? [英] Colon after method declaration?
本文介绍了方法声明后的冒号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public function getRecords(int $id): array;
有人可以告诉我在PHP接口内部的此方法声明中冒号在做什么吗?这是PHP 7语法,这里的含义是什么数组?方法必须返回数组或其他东西吗?
Hi, can someone tell me what colon is doing here, in this method declaration inside PHP interface? Is this PHP 7 syntax and what array is meaning here? Method must return array or something else?
推荐答案
是的,这是PHP 7中引入的新语法,用于声明该方法返回一个数组.
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
这篇关于方法声明后的冒号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文