我的代码就是这样
public function function1(){
$ client = new Google_Client();
$ client-> setAccessToken('Some value');
}
公共功能function2(){
//在这里,我想使用$ client-> getAccessToken()获取令牌。
}
如何在function2中使用来自function1的类的相同实例?因此,我可以在function2
中使用$ client-> getAccessToken()我的代码就像这个公共函数function1(){$ client = new Google_Client(); $ client-> setAccessToken('Some value'); } public funnction function2(){//这里我想使用$ ...
简单解决方案使用global