__ROOT__
__ROOT__ = $this->request->rootUrl()
abort(integer|\think\Response $code, string $message = null, array $header = array())
抛出HTTP异常
integer|\think\Response | $code | 状态码 或者 Response对象实例 |
string | $message | 错误信息 |
array | $header | 参数 |
app(string $name = 'think\App', array $args = array(), boolean $newInstance = false) : mixed|\think\App
快速获取容器中的实例 支持依赖注入
string | $name | 类名或标识 默认获取当前应用实例 |
array | $args | 参数 |
boolean | $newInstance | 是否每次创建新的实例 |
bind(string $abstract, mixed $concrete = null) : \think\Container
绑定一个类到容器
string | $abstract | 类标识、接口 |
mixed | $concrete | 要绑定的类、闭包或者实例 |
captcha(string $id = '', array $config = array()) : \think\Response
string | $id | |
array | $config |
classnames()
css样式名生成器 classnames("foo", "bar"); // => "foo bar" classnames("foo", [ "bar"=> true ]); // => "foo bar" classnames([ "foo-bar"=> true ]); // => "foo-bar" classnames([ "foo-bar"=> false ]); // => " classnames([ "foo" => true ], [ "bar"=> true ]); // => "foo bar" classnames([ "foo" => true, "bar"=> true ]); // => "foo bar" classnames("foo", [ "bar"=> true, "duck"=> false ], "baz", [ "quux"=> true ]); // => "foo bar baz quux" classnames(null, false, "bar", 0, 1, [ "baz"=> null ]); // => "bar 1"
container() : \think\Container
获取容器对象实例
controller(string $name, string $layer = 'controller', boolean $appendSuffix = false) : \think\Controller
实例化控制器 格式:[模块/]控制器
string | $name | 资源地址 |
string | $layer | 控制层名称 |
boolean | $appendSuffix | 是否添加类名后缀 |
db(string $name = '', array|string $config = array(), boolean $force = true) : \think\db\Query
实例化数据库类
string | $name | 操作的数据表名称(不含前缀) |
array|string | $config | 数据库配置参数 |
boolean | $force | 是否强制重新连接 |
get_category_byid(integer $id, boolean $self = false, integer $status, string $field = 'id', boolean $lang = false) : array|mixed
获取文章分类ids
integer | $id | 待获取的id |
boolean | $self | 是否返回自身,默认false |
integer | $status | 1表示只显示status=1的,0表示只显示status=0的,2表示不限制 |
string | $field | 默认只返回id数组(一维),其它如:"*"表示全部字段,"id,menu_name"表示返回二维数组 |
boolean | $lang | 是否只返回当前语言下分类,默认false |
json(mixed $data = array(), integer $code = 200, array $header = array(), array $options = array()) : \think\response\Json
获取\think\response\Json对象实例
mixed | $data | 返回的数据 |
integer | $code | 状态码 |
array | $header | 头部 |
array | $options | 参数 |
jsonp(mixed $data = array(), integer $code = 200, array $header = array(), array $options = array()) : \think\response\Jsonp
获取\think\response\Jsonp对象实例
mixed | $data | 返回的数据 |
integer | $code | 状态码 |
array | $header | 头部 |
array | $options | 参数 |
model(string $name = '', string $layer = 'model', boolean $appendSuffix = false) : \think\Model
实例化Model
string | $name | Model名称 |
string | $layer | 业务层名称 |
boolean | $appendSuffix | 是否添加类名后缀 |
redirect(mixed $url = array(), array|integer $params = array(), integer $code = 302) : \think\response\Redirect
获取\think\response\Redirect对象实例
mixed | $url | 重定向地址 支持Url::build方法的地址 |
array|integer | $params | 额外参数 |
integer | $code | 状态码 |
request() : \think\facade\Request
获取当前Request对象实例
response(mixed $data = array(), integer|string $code = 200, array $header = array(), string $type = 'html') : \think\Response
创建普通 Response 对象实例
mixed | $data | 输出数据 |
integer|string | $code | 状态码 |
array | $header | 头信息 |
string | $type |
route(string $rule, mixed $route, array $option = array(), array $pattern = array()) : \think\route\RuleItem
路由注册
string | $rule | 路由规则 |
mixed | $route | 路由地址 |
array | $option | 路由参数 |
array | $pattern | 变量规则 |
tree_left(array|mixed $tree, string $id_field = 'id', string $pid_field = 'pid', string $lefthtml = '─', integer $pid, integer $lvl, integer $leftpin) : array
返回按层级加前缀的树形数组
array|mixed | $tree | 待处理菜单数组 |
string | $id_field | 主键id字段名 |
string | $pid_field | 父级字段名 |
string | $lefthtml | 前缀 |
integer | $pid | 父级id |
integer | $lvl | 当前lv |
integer | $leftpin | 左侧距离 |
validate(string $name = '', string $layer = 'validate', boolean $appendSuffix = false) : \think\Validate
实例化验证器
string | $name | 验证器名称 |
string | $layer | 业务层名称 |
boolean | $appendSuffix | 是否添加类名后缀 |
view(string $template = '', array $vars = array(), integer $code = 200, callable $filter = null) : \think\response\View
渲染模板输出
string | $template | 模板文件 |
array | $vars | 模板变量 |
integer | $code | 状态码 |
callable | $filter | 内容过滤 |
xml(mixed $data = array(), integer $code = 200, array $header = array(), array $options = array()) : \think\response\Xml
获取\think\response\Xml对象实例
mixed | $data | 返回的数据 |
integer | $code | 状态码 |
array | $header | 头部 |
array | $options | 参数 |