PHP从静态函数更改变量

PHP从静态函数更改变量,php,class,oop,static,Php,Class,Oop,Static,我已经开始构建此类,我想注册一个用户: <?php class User { protected $_id; protected $_name; protected $_email; protected $_password; public $isLogged = false; public $errors = array(); public function __construct() { } public st

我已经开始构建此类,我想注册一个用户:

<?php
class User {
    protected $_id;
    protected $_name;
    protected $_email;
    protected $_password;
    public $isLogged = false;
    public $errors = array();

    public function __construct() {

    }
    public static function register($username,$email,$password,$captcha,$agree) {
        $user = new self;
        array_push($user->errors,'Error!');
    }
}
为什么它返回
成功
?我做了
array\u push

class User {

    // ...

    public static function register($username,$email,$password,$captcha,$agree) {
        $user = new self;
        array_push($user->errors,'Error!');
        return $user;
    }
}
您忘记从
register()
返回
$user
对象

您忘记从
register()
返回
$user
对象

您忘记从
register()
返回
$user
对象


您忘记从
register()

返回
$user
对象
register()
中没有返回任何内容
register()
中没有返回任何内容
register()
中没有返回任何内容
register()
class User {

    // ...

    public static function register($username,$email,$password,$captcha,$agree) {
        $user = new self;
        array_push($user->errors,'Error!');
        return $user;
    }
}