<?php
header("content-type:text/html;charset=utf-8");
class User{
public $name;
public $password;
function __construct($name,$password){
$this->name=$name;
$this->password=$password;
}
}
function f(User $user){ //这里User $user就是指定参数$user为类class User
echo $user->name.",".$user->password;
}
f(new User('小东','1234'));
?>
其它的类型都会报错