Home >Backend Development >PHP7 >About scalar type and return value type declaration in PHP7
A question: Are you writing code using new features?
Settings passed in Parameters, and return values of outgoing parameters<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(); }}
The above is the detailed content of About scalar type and return value type declaration in PHP7. For more information, please follow other related articles on the PHP Chinese website!