Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Cannot access private property #51

Open
xyz-caibing opened this issue May 13, 2021 · 1 comment
Open

Fatal error: Uncaught Error: Cannot access private property #51

xyz-caibing opened this issue May 13, 2021 · 1 comment

Comments

@xyz-caibing
Copy link

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

@TIGERB
Copy link
Owner

TIGERB commented May 13, 2021

/**
     * 魔法函数__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;
    }

魔术方法控制了的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants