Routing Problems and solutions in the ThinkPHPU method

Source: Internet
Author: User
In ThinkPHP2.0, using routes in the U method has obvious problems (bugs ). The following example describes the routing problems and solutions used in the ThinkPHPU method. Routing in the U method

In ThinkPHP 2.0, using routing in the U method has obvious problems (bugs ). The following section describes ThinkPHP
The example in routing usage is used as an example to illustrate the routing problems and solutions used in the ThinkPHP U method.

Route definition (if ThinkPHP 2.1RC is used
For more information, see ThinkPHP 2.1 route rule comparison 2.0 version change) as follows:




  1. Return array (
  2. // Regular route
  3. 'Product' => array ('products', 'show ', 'Category, product_id', 'status = 1 '),
  4. )

Corresponding URL
An example of an access address is as follows:

Index. php/product/5/123

According to the ThinkPHP2.0 full development manual example, use this route in the U method:

Href = "{: U ('product @? Category = 3 & product_id = 123 ')} "> Product Details

Generated
The URL is as follows:

Href = "index. php/product/category/3/product_id/123"> product Details

Apparently generated
URL
The address is incorrect.
Use routing in the U method

To use routing in the U method, manually write the route according to the actual URL address. the preceding example is written as follows:

Href = "{: U ('product/000000')}"> product Details

If a project group or URL parameter delimiter is-
And so on:




  1. // Project Group
  2. U ('admin/product/8080 ')
  3. // The parameter delimiter is-
  4. U ('product/3-123 ')
  5. // Project group. The parameter delimiter is-
  6. U ('admin-product/3-123 ')
  7. // An example where the parameter separator is-and the parameter is a variable
  8. U ('product/'. $ _ GET ['cat _ id'].'-'. $ list ['product _ id'])

Routing bug used in the U method in ThinkPHP 2.0
And only hope to be improved and solved in later versions.

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.