相关疑难解决方法(0)

如何在静态方法中调用类的成员变量?

我正在使用一些方法来自动加载带有函数的辅助文件.我现在唯一的问题是如何调用该类中的变量.

因为我没有将它实例化为对象,所以$this无法工作.但是会是什么?

class some_helperclass {

var $some_variable  = '007';

public static function some_func()
    {
    //return 'all ok';
    if (self::some_variable !== FALSE)  
    {
       return  self::ip_adres;
    }
}
Run Code Online (Sandbox Code Playgroud)

我现在可以在任何地方调用该功能spl_autoload_register().

some_helperclass:: some_func();
Run Code Online (Sandbox Code Playgroud)

php variables static-methods class

10
推荐指数
2
解决办法
1万
查看次数

标签 统计

class ×1

php ×1

static-methods ×1

variables ×1