Passing variables between thinkphp methods
First use object-oriented often this is the case that two methods need to be used in the same way that I read some data from the database in a method to the template and then I find that another method in the same module needs to use this data or one of the variables I don't know what to do. Ask for the big wet to speak Clear Point Ha younger brother rookie
------Solution--------------------
You can define public methods in comment/comment.php, which can be called anywhere.
------Solution--------------------
First write an action that commonaction inherits thinkphp, the code is as follows:
Commonaction extends action{}
Then you inherit the commonaction with all the normal actions, so that the common method is written in Commonaction, and then the common method is called in different child action.
------Solution--------------------
Write it again in the way you need it.
Note that the normal execution of the display method means that the program is finished
Different methods in the same controller are not executed in the same HTTP session, so they are all independent. It's just that you wrote it together.
If other methods need to be called before the display method is executed, the called method uses the same data set as the caller
Then you can put the data set in the Init method