构造函数不会获得返回值。它们完全用于实例化该类。
在不调整您已经在做的事情的情况下,您可以考虑在此处使用异常。
public function __construct ($identifier = NULL){ $this->emailAddress = $identifier; $this->loadUser();}private function loadUser (){ // try to load the user if () { throw new Exception('Unable to load user using identifier: ' . $this->identifier); }}现在,您可以以这种方式创建新用户。
try { $user = new User('user@example.com');} catch (Exception $e) { // unable to create the user using that id, handle the exception}


