0803THINKPHP Basics: Load pages, requests, common classes, common methods, get variables

Source: Internet
Author: User

class, method, function ==========================================================

First, load the page

1. System functions

return view ();

2. System View Class

$view = new View ();

return $view->fetch ();

3, through the Controller class

Requires the controller to inherit the system class

return $this->fetch ();

Second, obtain the request class

1. System functions

$request = Request ();

2. System Request Class

Use Think\request;

Because the request class is a singleton pattern, all objects cannot be instantiated with new, and methods are invoked using the class itself

$request = Request::instance ();

3. System Request Class

Use Think\request;

Using method calls

Public Function Index (Request $request) {

Dump ($request);

}

Third, common system class

1. config Configuration class

2 Controller class

3. ENV Environment Class

4. Route Routing Class

5. URL URL class

6. View class

7. Requests Request Class

Iv. Common system methods

1. Dump () formatted output

2. Controller () Call controllers

3. Action () Call method

4. config () Read and set configuration file

5. URL () Generate URL address

6. View () load page

7. Request () Instantiation Request Class

User Request =============================================================

First, obtain the user request information

1. Get the domain name

Dump ($request->domain ());

2. Get the URL address

Dump ($request->url ());

3. Get the entry file

Dump ($request->basefile ());

4. Get PathInfo Path

Dump ($request->pathinfo ());

5. Get path

Dump ($request->path ());

6, get the URL address pseudo-static suffix (pseudo-static is the path disguised as static pages, so that the search engine better revenue site, to prevent others to know the real language of the site development)

Dump ($request->ext ());

Second, obtain the request module, the controller, the method

1. Module

$request->module ();

2. Controller

$request->controller ();

3. Methods

$request->action ();

Third, GET request parameters

$request = Request::instance ();

1. Echo ' request method:'. $request->method (). ' <br/> ';

2. Echo ' resource type:'. $request->type (). ' <br/> ';

3. Echo ' access address:'. $request->ip (). ' <br/> ';

4, Echo ' whether AJax request:'. Var_export ($request->isajax (), true). ' <br/> ';

5, echo ' request parameter:';

Dump ($request->param ());

6, Echo ' request parameter: Contains only name ';

Dump ($request->only ([' name ']));

7, echo ' request parameter: Exclude name ';

Dump ($request->except ([' name ']));

Iv. Request Type Judgment

1. System class

Determine if a GET request

Dump ($request->isget ());

Determine if the phone is the end

Dump ($request->ismobile ());

2. System functions

Determine if a GET request

Dump (Request ()->isget ());

Determine if the phone is the end

Dump (Request ()->ismobile ());

Get variable ==============================================================

First, determine whether the existence of variables

    

0803THINKPHP Basics: Loading pages, requests, common classes, common methods, getting variables

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.