开发者

What to use istead of THIS in php OOP?

开发者 https://www.devze.com 2023-03-15 10:51 出处:网络
I have a static class that loads additional php file inside of one of its function and I need to access class variables from this file withous knowing the class name.

I have a static class that loads additional php file inside of one of its function and I need to access class variables from this file withous knowing the class name.

But This::SomeVar - doesn't work.

But I know there's another way to do it, I just can't find anything ab开发者_JAVA技巧out it.

So here's the example class

class SomeClass {
    static function Initialize() {
        require_once 'somefile.php';
    }
}

and inside that file I need to access static variable something like this

This::SomeVar= 'qwe';


Use self::$SomeVar to access static class members.


$this->someVar for fields and self::$someVar for statics


You can use $this->someVar to access a property from inside a class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号