There are many ways to call session data in the template of the ThinkPHP framework, which can be used flexibly according to the situation. The common ones are as follows:
1. Directly call {$Think.session} in the template to obtain the session;
2. Write php code directly in the
3. Write in the template, and then write php code directly in it to call $_SESSION;
4. In Action, assign the $_SESSION variable to the template through the assign() method;
5. In the custom function library, create a new function to return the $_SESSION variable, and then use the {$ variable command in the template file | Function name} to assign the $_SESSION returned by the function to a variable in the template
In addition to the above 5 methods, readers can also develop new calling methods according to their own preferences.
I hope this article will help you design PHP programs based on the ThinkPHP framework.
For more related articles on how to call session data in ThinkPHP templates, please pay attention to the PHP Chinese website!