查看以下代码,我看到构造函数正在返回一个值。我认为构造函数只返回对象。有人能告诉我我错过了什么吗?
public function __construct($username = null, $password = null){
$urlLogin = "{$this->apiHost}/login/$username";
$postData = sprintf("api_type=json&user=%s&passwd=%s",
$username,
$password);
$response = $this->runCurl($urlLogin, $postData);
if (count($response->json->errors) > 0){
return "login error";
} else {
$this->modHash = $response->json->data->modhash;
$this->session = $response->json->data->cookie;
return $this->modHash;
}
}