The use U function method of a tag href band parameter in thinkphp template

Source: Internet
Author: User
Tags parse error php framework

Basically, the link address in the template category.

Achieve this kind of like

<a href= "/index.php/home/category/assortment/cateid/2.html" > Mobile wallpaper </a>

Problem:

The problem you started with is that you can't parse

{$category. ID} seems to be the result of parsing the outside U function {} should use $category["id"]
<volist name= "Cate" id= "category" >                    <span><a href= "{: U (' category/assortment?cateid={$ Category. ID} ')} ">{$category.categroyname}</a></span>                    </volist>

<volist name= "Cate" id= "category" ><span><a href= "{: U (' category/assortment?cateid=$category [' id '] ')} ">{$category.categroyname}</a></span></volist>

But it's still an error.

First error:

:(
Syntax error, unexpected ' "]),?>" ' (t_constant_encapsed_string), expecting ', ' or '; '
Wrong location
file:d:\wamp\www\apps\runtime\cache\home\04413e880c54d4e5faa7054dbe0160f3.php line:226
ThinkPHP3.2.3 {Fast & simple OOP PHP Framework}--[WE CAN do IT JUST THINK]

A second error

PHP Parse error:syntax error, unexpected ' id ' (t_string) in D:\www\apps\Runtime\Cache\Home\ 04413e880c54d4e5faa7054dbe0160f3.php on line 227

Solution directly with the U function to pass the parameter

The following can be used as normal parsing

<volist name= "Cate" id= "category" >                    <span><a href={:u (' category/assortment ',array(' Cateid ' =$category["id]])} >{$category.categroyname}</a></span>                    </ Volist>

When a href uses "", there will be an error, but it can also parse correctly

<span><a href= "{: U (' category/assortment ', Array (' cateid ' = ' $category [" id "])}" >{$ Category.categroyname}</a></span>

Do not know this is not standard can not

The use U function method of a tag href band parameter in thinkphp template

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.