Thinkphp introduces a public class that does not need to instantiate calls in other methods
Text ("Hello, I ' m WeChat")->reply (); It is not possible to invoke the above instantiated class//operation to use} public function test () {$weObj->text ("Hello, I ' m WeChat")->reply (); You cannot invoke the class that you instantiated above//How to do this in order to use }}
Reply to discussion (solution)
This is a class that creates a public variable ....
How to create it, I've tried it like I can't inherit
Class Wuyecontroller extends Checkcontroller { protected $wechat; protected function _initialize () { $token = ' weixin ';//tokens $this->wechat = new WeChat ($token); } Public Function Index () { $this->weobj->text ("Hello, I ' m WeChat")->reply (); } Public Function test () { $this->weobj->text ("Hello, I ' m WeChat")->reply ();} }
Thank you for the reply, but still no, prompt to a member function text () on a non-object
Which is that there is no instantiation of success
The class library I'm using is this.
Https://github.com/dodgepudding/wechat-php-sdk
Where to put your class library files, you need to introduce files and try again, import or vendor.
The class library is correct and I can refer to it correctly in _initialize, but in other ways it cannot be referenced
Change the protected of the initialization method to public, then write on the third floor.
The Checkcontroller class definition was not found in the Wechat-php-sdk-master project
And I didn't find the definition of the _initialize method.
Can you confirm that _initialize was executed when the class was instantiated?
Token as the identity authentication, usually is the dynamic release, you write Dead can?
This class can be used directly in the _initialize.
Token is just a parameter of the class, no plus, but why can't it be used in TP?
I saw a WeChat and a weobj ...
Weobj = new Wechat ($token); } Public Function Index () { $this->weobj->text ("Hello, I ' m WeChat")->reply (); It is not possible to invoke the above instantiated class //How to use the } public function test () { $this->weobj->text ("Hello, I ' m WeChat ")->reply (); You cannot invoke the class that you instantiated above //How to do this in order to use }}