ThinkPHPthinkphp5.0 | 请求\think\Request $request = Request::instance(); 也可以使用助手函数 $request = request(); 获取url信息 $request = Request::instance(); // 获取当前域名 echo 'domain: ' . $request->domain() . ''; // 获取当前入作者王明昌发布时间2019-02-11复制\think\Request $request = Request::instance(); 也可以使用助手函数 $request = request(); 获取url信息 $request = Request::instance(); // 获取当前域名 echo 'domain: ' . $request->domain() . ''; // 获取当前入口文件 echo 'file: ' . $request->baseFile() . ''; // 获取当前URL地址 不含域名 echo 'url: ' . $request->url() . ''; // 获取包含域名的完整URL地址 echo 'url with domain: ' . $request->url(true) . ''; // 获取当前URL地址 不含QUERY_STRING echo 'url without query: ' . $request->baseUrl() . ''; // 获取URL访问的ROOT地址 echo 'root:' . $request->root() . ''; // 获取URL访问的ROOT地址 echo 'root with domain: ' . $request->root(true) . ''; // 获取URL地址中的PATH_INFO信息 echo 'pathinfo: ' . $request->pathinfo() . ''; // 获取URL地址中的PATH_INFO信息 不含后缀 echo 'pathinfo: ' . $request->path() . ''; // 获取URL地址中的后缀信息 echo 'ext: ' . $request->ext() . ''; 模板/控制器/方法 $request = Request::instance(); echo "当前模块名称是" . $request->module(); echo "当前控制器名称是" . $request->controller(); echo "当前操作名称是" . $request->action(); 设置模块名称值需要向module方法中传入名称即可,同样使用于设置控制器名称和操作名称 Request::instance()->module('module_name'); 获取请求参数 $request = Request::instance(); echo '请求方法:' . $request->method() . ''; echo '资源类型:' . $request->type() . ''; echo '访问ip地址:' . $request->ip() . ''; echo '是否AJax请求:' . var_export($request->isAjax(), true) . ''; echo '请求参数:'; dump($request->param()); echo '请求参数:仅包含name'; dump($request->only(['name'])); echo '请求参数:排除name'; dump($request->except(['name'])); 获取路由和调度信息 hello方法修改如下: $request = Request::instance(); echo '路由信息:'; dump($request->route()); echo '调度信息:'; dump($request->dispatch()); 路由定义为: return [ 'hello/:name' =>['index/hello',[],['name'=>'\w+']], ]; 访问下面的URL地址: http://serverName/hello/thinkphp 输出信息为: 路由信息: array (size=4) 'rule' => string 'hello/:name' (length=11) 'route' => string 'index/hello' (length=11) 'pattern' => array (size=1) 'name' => string '\w+' (length=3) 'option' => array (size=0) empty 调度信息: array (size=2) 'type' => string 'module' (length=6) 'module' => array (size=3) 0 => null 1 => string 'index' (length=5) 2 => string 'hello' (length=5) 设置请求信息 $request = Request::instance(); $request->root('index.php'); $request->pathinfo('index/index/hello');
2018-02-27tp5controller与model使用数据库控制器里使用数据库 use think\Db; $info = Db::table('fly_user')->select();//用些前缀,全部查询 $info = Db::table('fly_u
2018-04-30TP5错误 | A non well formed numeric value encountered数据表字段是create_time timestamp 默认:CURRENT_TIMESTAMP 使用时间会出现以下错误: A non well formed numeric value encoun
2018-02-02tp3.2-if三层嵌套问题if标签 value1 value2 value3 if标签不支持三层嵌套,所以第三层不要用if标签,用eq标签;就能解决三层嵌套。 相等不相等 还有更多比较标签可以使用 http://documen
2018-07-04转载 | ThinkPHP5+Layui实现图片上传加预览 图片 上传图片 layui.use('upload',function(){ var upload = layui.upload, jq = layui.jquery; upload.render