站长资源
中国站长网站

thinkphp怎么在模板中获取url的参数

对于普通的url获取很简单的,无论是你在html文件中用js来获取还是在php文件中用get来获取都可以,但是pathinfo类型的url获取起来就有点烦人,tinkphp提供了内置的request对象来帮助我们获取,具体如下:

// 调用Request对象的get方法 传入参数为id
{$Request.get.id}
// 调用Request对象的param方法 传入参数为name
{$Request.param.name}
// 调用Request对象的param方法 传入参数为user.nickname
{$Request.param.user.nickname}
// 调用Request对象的root方法
{$Request.root}
// 调用Request对象的root方法,并且传入参数true
{$Request.root.true}
// 调用Request对象的path方法
{$Request.path}
// 调用Request对象的module方法
{$Request.module}
// 调用Request对象的controller方法
{$Request.controller}
// 调用Request对象的action方法
{$Request.action}
// 调用Request对象的ext方法
{$Request.ext}
// 调用Request对象的host方法
{$Request.host}
// 调用Request对象的ip方法
{$Request.ip}
// 调用Request对象的header方法
{$Request.header.accept-encoding}

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » thinkphp怎么在模板中获取url的参数

评论 抢沙发

评论前必须登录!