When do I need to add a colon Before the method in the ThinkPHP template?

Source: Internet
Author: User
For example, I want to link to the home page in the navigation bar: & quot; {U (& #039; IndexIndex & #039;)} & quot; cannot be properly linked to the home page. Write it as follows: & quot; {: U (& #039; IndexIndex & #039;)} & quot; (a colon is added before the U method), I am in another place, in a form: & amp; lt; formaction & quot; metho... for example, I want to link to the home page in the navigation bar:
Written as follows: "{U ('index/Index ')}"
Cannot be correctly linked to the home page.
Write it as follows: "{: U ('index/Index ')}"
(That is, the colon is added before the U method)

However, I am in another place, in a form:


There is no problem if you do not add a colon Before the U method!

Why?

Reply content:

For example, I want to link to the home page in the navigation bar:
Written as follows: "{U ('index/Index ')}"
Cannot be correctly linked to the home page.
Write it as follows: "{: U ('index/Index ')}"
(That is, the colon is added before the U method)

However, I am in another place, in a form:

There is no problem if you do not add a colon Before the U method!

Why?

1,U()Is the URL generation function in ThinkPHP.
2. In the template, use{:U('home/index')}This method means:
3. If you only want to write{U('home/index')}It should be understood as invalid (or it may be executed but no echo) and has not been tested; LZ says that adding a colon in form is okay. It may be because the write is invalid and nothing is output, so it becomesIn the form tag, if action is null, it is submitted to the current page by default. So ..

Link Description

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.