Thinkphp object-oriented
Public $ allWord = array (); // Set attributes
$ This-> allWord = $ logs; // value in the Index method
Dump ($ this-> allWord); // print it in the wordInfo method
Access the wordInfo method and the result is null. Sorry, please wait online !!
Reply to discussion (solution)
How did you access the index method before accessing the wordInfo method?
Yes. write an Export button in the Index method. the button jumps to the wordInfo method.
Okay, go home for dinner, upload Baidu Cloud, go home and change .. Thank you!
Button jump to wordInfo method?
The index is not executed. of course, it is null.
That's what I think! I first run the Index method, assign a value to the attribute in the Index method, and then jump to the wordInfo method .. So we should get the value.
Instead of calling the wordInfo method
It is incorrect because it is another request.
If I return the logs array of the Index method, then in the constructor $ this-> allWord = $ this-> index ();
Then, you can call the attribute in wordInfo?
This is equivalent to executing the Index method in the constructor when I execute wordInfo. are the input conditions in the Index method reset? It is not the value obtained from the constructor attribute. it is the value of index return for the first time. Right?
Yes
You need to remember that http is stateless and there is no connection between each request.
Thank you. I just want to try a method that is not feasible .. There are many ways to implement functions. I just want to find the simplest and least code method. it seems that it is not feasible.