easy-php icon indicating copy to clipboard operation
easy-php copied to clipboard

Fatal error: Uncaught Error: Cannot access private property

Open xyz-caibing opened this issue 3 years ago • 1 comments

class App { private $rootPath; } class Load { public static function register(App $app) { self::$namespaceMap = [ 'Framework' => $app->rootPath ]; } } 这里的app->rootPath 是私有的,应该只有App类内部可以使用

xyz-caibing avatar May 13 '21 05:05 xyz-caibing

/**
     * 魔法函数__get
     *
     * @param  string $name  属性名称
     * @return mixed
     */
    public function __get($name = '')
    {
        return $this->$name;
    }

    /**
     * 魔法函数__set
     *
     * @param  string $name   属性名称
     * @param  mixed  $value  属性值
     * @return mixed
     */
    public function __set($name = '', $value = '')
    {
        $this->$name = $value;
    }

魔术方法控制了的

TIGERB avatar May 13 '21 08:05 TIGERB