所以基本上我明白这一点......
class User
{
function __construct($id) {}
}
$u = new User(); // PHP would NOT allow this
我希望能够使用以下任何参数进行用户查找,但至少需要一个,同时保留 PHP 提供的默认错误处理(如果没有传递参数)...
class User
{
function __construct($id=FALSE,$email=FALSE,$username=FALSE) {}
}
$u = new User(); // PHP would allow this
有没有办法做到这一点?