Methods for calling session data in a thinkphp template _php instance

Source: Internet
Author: User

There are many ways to invoke the session data in the templates of the thinkphp framework, which can be used flexibly according to the situation, and the following categories are common:

1. Call {$Think. session} directly in the template to get the session;

2. In <php></php> tags directly to write PHP code to invoke $_session data;

3. Write <?php in the template, and then directly write PHP code inside to invoke $_session;

4. In action, the $_session variable is assigned to the template by the Assign () method;

5. In the Custom function library, create a new function to return the $_session variable, and then use the {$ variable | function name} in the template file 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.

More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Template Operation Skills Summary", "thinkphp Common Methods Summary", "Smarty Template Introductory Course" and "PHP template technology Summary."

I hope this article will help you with the PHP program design based on thinkphp framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.