設定傳入參數,與傳出參數返回值<pre class="brush:php;toolbar:false">class Person(){
public function name(string $name):string {
return "名称:".$name;
}
public function age(int $age):string {
return "年龄:".$age;
}}</pre>
class Address(){ public function getAddress(int $age):string { return ['street'=>'street1','country'=>'china']; }}class Person(){ public function name(string $name):string { return "名称:".$name; } public function age(int $age):string { return "年龄:".$age; } public function age(int $age):Address { return new Address(); }}
以上是關於PHP7之標量類型與回傳值類型聲明的詳細內容。更多資訊請關注PHP中文網其他相關文章!