search
Homephp教程php手册tp中u方法的使用,tpu方法使用

tp中u方法的使用,tpu方法使用

自学的时候都没怎么使用过该方法,现在刚进入一个新公司参加项目。发现这个方法用的很多,所以记录下来防止以后忘了。

U方法用于完成对URL地址的组装,特点在于可以自动根据当前的URL模式和设置生成对应的URL地址,格式为:

U('地址','参数','伪静态','是否跳转','显示域名');

<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'));

当在模板中使用U方法时,好处在于:一旦你的环境变化或者参数设置改变,你不需要更改模板中的任何代码。

在模板中的调用格式需要采用 {:U('地址', '参数'…)} 的方式

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

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools