我想知道方法名称后冒号的含义即
公共函数 getTitle():Data {
interface Data {
public function details(string $name);
}
class Company {
private $title;
public function getTitle():Data {
return $this->title;
}
public function setTitle(Data $title)
{
$this->title=$title
}
}
.....
.....
Run Code Online (Sandbox Code Playgroud)
public function getTitle():Data {
return $this->title;
}
Run Code Online (Sandbox Code Playgroud)
“返回类型声明”自 PHP 7.0 起添加(此方法应返回类型为“Data”的对象)。
与“参数类型声明”一样,“返回类型声明”是可选的。
检查 PHP 7.0 中引入的新功能
检查此链接 http://php.net/manual/en/migration70.new-features.php
归档时间: |
|
查看次数: |
1068 次 |
最近记录: |