ThinkPHP
thinkphp5.0 | 数据库
配置数据库 https://www.kancloud.cn/manual/thinkphp5/118059 原生sql query(查询) execute(写入) Db::query('select * from think_user where id=?',[8]); Db::execute('insert into think_user (id, nam
thinkphp5.0 | 视图
// 渲染模板输出 return $this->fetch('hello',['name'=>'thinkphp']); 方法 说明 fetch 渲染模板输出 display 渲染内容输出 assign 模板变量赋值 engine 初始化模板引擎 助手函数 view('[模板文件]'[,'模板变量(数组)'][,模板替换(数组)]) return view(
thinkphp5.0 | 方法注入属性注入
方法注入 如果你需要在Request请求对象中添加自己的方法,可以使用Request对象的方法注入功能,例如: // 通过hook方法注入动态方法 Request::hook('user','getUserInfo'); getUserInfo函数定义如下 function getUserInfo(Request $request, $userId) { /
thinkphp5.0 | 请求类型请求伪装header头信息伪静态
判断请求类型 // 是否为 GET 请求 if (Request::instance()->isGet()) echo "当前为 GET 请求"; // 是否为 POST 请求 if (Request::instance()->isPost()) echo "当前为 POST 请求"; // 是否为 PUT 请求 if (Request::instance(
thinkphp5.0 | 输入变量更改变量
输入变量 可以通过Request对象完成全局输入变量的检测、获取和安全过滤,支持包括$_GET、$_POST、$_REQUEST、$_SERVER、$_SESSION、$_COOKIE、$_ENV等系统变量,以及文件上传信息。 检测是否存在has Request::instance()->has('id','get'); input('?get.id');
thinkphp5.0 | 请求
\think\Request $request = Request::instance(); 也可以使用助手函数 $request = request(); 获取url信息 $request = Request::instance(); // 获取当前域名 echo 'domain: ' . $request->domain() . ''; // 获取当前入
thinkphp5.0 | 控制器
// 修改应用类库命名空间 'app_namespace' => 'application', namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { // 获取包含域名的完整URL地址 $
thinkphp5.0 | 配置
读取配置 echo Config::get('配置参数1'); echo config('配置参数1'); dump(Config::get());//所有配置 Config::has('配置参数2');//判断配置是否存在 echo config('配置参数.二级参数'); 设置配置 Config::set('配置参数','配置值'); // 或者使用助手
thinkphp5.0 | 安装thinkphp
环境要求: PHP >= 5.4.0 PDO PHP Extension MBstring PHP Extension CURL PHP Extension 1. 官网下载 http://www.thinkphp.cn/down.html 2.composer composer create-project topthink/think=5.0.* tp5