2.TinkPHP Getting Started----controller

Source: Internet
Author: User

1. Controller creation

naming rules: Controller name +controller+.class.php,

For example GoodsController.class.php UserController.class.php

Controller Structure Code:

declares the current controller's namespace -- introduces the parent class controller - - declares the controller and inherits the parent class

2. route form 2.1 Normal form routing (get form route)

Routing form:http://localhost:84/index.php?m=Home&c=User&a=test&id=1

2.2pathinfo Routing form

Routing form:http://localhost:84/index.php/Home/User/test/id/100

2.3rewrite Routing form

Routing form:Http://localhost:80/Home/User/test/id/1/name/bill

Compared with the tinkphp default route form, the portal file is less than that, and the route cannot be used directly, it needs to be used after the configuration is completed .

Configuration steps:

1. Modify http.conf file: Remove LoadModule rewrite_module modules/mod_rewrite.so notes;

2. Modify the virtual host file httpd-vhosts.conf to add subordinate configuration to the site you want to rewrite

3. Restart Apache

4. Copy the . htaccess from the thinkphp compressed package to the index.php 's sibling directory

Note:PHP has a total of several operating modes, each running mode using the htaccess file method is different, this route form requires Apache Support, So the third route is not recommended for general use

2.4. compatible routing forms

Routing form:http://locaohost:84/index.php?s=/Home/User/test/id/1

3. about tinkphp Road form configuration

The configuration file of the routing form in the thinkphp system is embodied

Special Note : The configuration value of the routing form does not affect the way we enter other forms of routing access in the address bar, which affects the build URL of the assembly function that thinkphp the package URL of the system. The form of an address

4. Grouping

Group: The general project will be based on a function of the use of objects to differentiate the code, this time put together after recalling a folder, this file can be called a grouping, grouping is what we usually refer to the platform. For example , in a newly deployed thinkphp, home is a grouped directory .

How do I create a grouping?

5. jumps in the controller 5.1.URL Assembly

URL assembly is a URL based on a rule , in the thinphp System provides a package of HA un number to handle URL assembly, this method is called the u method

5.2.U Syntax format

U (' URL path ', parameter array ), e.g. u (' index ')

5.3 System Jump method

successful jump : $this->success ( jump prompt, jump address, wait time ),where parameter 1 is required parameter, If there is no jump address default back to previous page

failed jump : $this->error ( jump prompt, jump address, wait time )

2.TinkPHP Getting Started----controller

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.