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:
- Return array (
- // Regular route
- 'Product' => array ('products', 'show ', 'Category, product_id', 'status = 1 '),
- )
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:
- // Project Group
- U ('admin/product/8080 ')
- // The parameter delimiter is-
- U ('product/3-123 ')
- // Project group. The parameter delimiter is-
- U ('admin-product/3-123 ')
- // An example where the parameter separator is-and the parameter is a variable
- 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.