Access global variable from within a class

前端 未结 4 1010
轮回少年
轮回少年 2020-12-04 02:00

I have the following (stripped down) code:



        
4条回答
  •  北海茫月
    2020-12-04 02:07

    You will need to define it as a global variable inside the scope of the function you want to use it at.

    function __construct() {
        global $a;
        $a->Show();
    }
    

提交回复
热议问题