Thinkphp object-oriented

Source: Internet
Author: User
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.

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.