Home >Backend Development >PHP Tutorial >Use of u method in tp

Use of u method in tp

WBOY
WBOYOriginal
2016-08-08 09:31:281305browse

I have never used this method much when I was studying on my own, and now I have just joined a new company to participate in a project. I found that this method is used a lot, so I recorded it to prevent forgetting it later.

The

U method is used to complete the assembly of URL addresses. Its feature is that it can automatically generate the corresponding URL address based on the current URL mode and settings. The format is:

U('Address', 'Parameters', 'Pseudo-static', 'Whether to jump', 'Display domain name');

<span>1</span> <span>//</span><span>比如操作成功跳转到Store模块下的Ump控制器中的lists方法</span>
<span>2</span> <span>$this</span>->success('新增成功',U('Strore/Ump/lists'));

<span>1 //</span><span>跳转时带着参数的话</span>
<span>2 $this</span>->success('新增成功',U('Store/Ump/lists','type=1&id=1'));

When using the U method in a template, the advantage is that once your environment changes or parameter settings change, you do not need to change any code in the template.

The calling format in the template needs to be in the form of {:U('address', 'parameter'...)}

<span><!--</span><span>在模板中使用U方法 </span><span>--></span><span>
{:U('Store/Ump/lists','type=1</span><span>&id</span>=1')}

The above introduces the use of the u method in tp, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn