
thinkphp
k7Cx7e
这个作者很懒,什么都没留下…
展开
-
composer安装thinkphp及vendor教程
下载composercurl -sS https://getcomposer.org/installer | php全局安装mv composer.phar /usr/local/bin/composer修改为国内镜像composer config -g repo.packagist composer https://packagist.phpcomposer.com切换到根目录,下载...原创 2017-03-17 19:36:05 · 2592 阅读 · 0 评论 -
thinkphp5 mysql insert 返回自增ID
使用insertGetId方法新增数据并返回主键值:Db::name('user')->insertGetId($data);原创 2019-10-29 11:14:01 · 2272 阅读 · 0 评论 -
thinkphp5 保存微信昵称出错的解决办法
首先,把mysql数据库字符集改为utf8mb4_general_ci然后,把thinkphp的database.php的数据库编码改为utf8mb4。原创 2019-08-06 08:51:52 · 896 阅读 · 0 评论 -
Thinkphp5 Request 获取不到微信支付回调参数
方法是用 file_get_contents("php://input"); 不建议用$GLOBALS['HTTP_RAW_POST_DATA'],因为php7以后已经被移除。$GLOBALS['HTTP_RAW_POST_DATA']在未来的版本会被移除掉,官方推荐读取流。也就是php://input...转载 2019-06-01 16:51:03 · 1644 阅读 · 0 评论 -
thinkphp5.0 跨模块调用模板
不同模块共用一个header.htm文件,现在header.htm默认的home组里,在user组里如何引用这个模板的?引用方式:<include file="home@Index/header" />转载 2019-01-25 21:37:24 · 3049 阅读 · 0 评论 -
thinkphp5.0 内置验证码的使用
1、thinkphp5.0已内置验证码,只需直接在模板文件添加{:captcha_img()}即可显示验证码。2、优化:编辑\vendor\topthink\think-captcha\src\helper.php 文件,替换下面的 captcha_img() 方法代码:function captcha_img($id = ""){ $js_src = "this.s...原创 2019-01-25 13:10:48 · 716 阅读 · 0 评论 -
Thinkphp5.0读取自定义拓展配置extra
//新建配置文件,位置application/extra/user.php//文件内容格式return [ "name"=>"xiaoli", "age"=>15];//先引用use think\Config;//读取自定义拓展配置dump(config('user'));dump(config('user.name')); ...原创 2018-12-11 23:18:17 · 3402 阅读 · 0 评论 -
thinkphp5.0验证器验证两次密码是否一致
1、验证规则:'new_password'=>'require|min:6|confirm'2、验证错误提示'new_passwd.require' => '新密码必填','new_passwd.min' => '密码必须6位以上','new_passwd.confirm' => '两次密码不一致',//confirm自动相互验证3、实例化,并获取验...原创 2018-12-16 17:42:30 · 3501 阅读 · 0 评论 -
thinkphp5.0 通过phpspreadsheet导出到excel
首先,进入thinkphp的根目录修改为国内源composer config repo.packagist composer https://packagist.phpcomposer.com然后composer require phpoffice/phpspreadsheet最后就是在thinkphp中引入使用了。use PhpOffice\PhpSpreadsheet\Spr...原创 2018-12-21 01:44:10 · 1938 阅读 · 1 评论 -
thinkphp5.0 链式操作(同时更新和自增加)
链式操作方式是thinkphp官方推荐的,官方例子:Db::table('data') ->where('id',1)//条件 ->inc('read')//自增加1 ->dec('score',3)//自减少1 ->exp('name','UPPER(name)')//表达式 ->update();模型(model)...原创 2018-12-13 22:32:27 · 2169 阅读 · 0 评论 -
H-UI 和thinkphp5组合的ajax提交问题
涉及三个页面:1、模板页面。只需<form><input type="submit"></form>,无需action和method2、js脚本 <!--请在下方写此页面业务相关的脚本--> <script type="text/javascript"> $(function(){ $("#ad原创 2018-10-25 17:03:44 · 724 阅读 · 0 评论 -
thinkphp5.0 解决保存微信昵称时出错的问题
其实,本质是数据库字符集的问题。1、把字段改为utf8mb4_general_ci2、把thinkphp的database.php的数据库编码改为utf8mb4即可。原创 2018-10-19 09:54:10 · 1360 阅读 · 0 评论 -
thinkphp5.0 endroid/qr-code[生成二维码]的生成
详细使用说明这里不再啰嗦,看官方说明:https://packagist.org/packages/endroid/qr-code需要注意的是,有基础用法和拓展用法。基础用法比较简单,拓展用法就比较复杂。实际使用显示图片的方法:1、获取生成图片的php地址;2、在通过img标签引用这个地址就可以显示了...原创 2018-10-16 10:57:56 · 1805 阅读 · 0 评论 -
Thinkphp 模板中数字格式化的方法
1.number_format {$number|number_format=2} 千分位,保留两位小数2.round {$number|round=2} 四舍五入保留两位小数转载 2018-10-16 09:19:20 · 5645 阅读 · 0 评论 -
Centos thinkphp5.0 链接sql server的pdo_dblib扩展
首先,安装Freedts然后,下载扩展包,上传到thinkphp/library/think/db目录下。最后,thnikphp的database.php的数据库类型修改为 'type'=> 'dblib'扩展包下载:https://download.youkuaiyun.com/download/gdali/10682405...原创 2018-09-22 12:06:33 · 692 阅读 · 0 评论 -
thinkphp5.0 Call to a member function assign() on null的解决办法
控制器里面写了一个构造函数,结果运行出错提示Call to a member function assign() on null原来里面写了一个_initialize()的方法,原来是子类的构造函数覆盖了父类的,所以报错了。解决办法:将__construct()改为_initialize()...原创 2018-09-25 10:14:09 · 7485 阅读 · 0 评论 -
thinkphp request 和 param 的区别
thinkphp 5的param不是一般的强大。//param 是thinkphp自己写的类型,自动判断是什么类型的数据 就行接收。//无论什么类型都可以接受,包括php://input 这种原生数据流客户端POST签名信息到服务端(签名后用&串联)namespace app\bindex\controller;use think\Request;clas转载 2017-01-17 20:21:14 · 11255 阅读 · 0 评论