Thinkphp图片水印和文字水印
1.Thinkphp图像处理
1.1图片处理类和库
首先,在Thinkphp\Think\Image类中有图像处理功能,支持Gd库和Imagick库,包括对GIf图像处理的支持。
1.2实例化类库
$image = new \Think\Image();
实例化image后,默认使用GD库进行图像操作,如果需要使用Imagick...
thinkphp二级域名配置
官方文档
http://document.thinkphp.cn/manual_3_2.html#domian_deploy
以下内容来自网络
首先是在config.php文件中开启二级域名配置
'APP_SUB_DOMAIN_DEPLOY' => true
然后配置二级域名规则如下
'APP_SU...
thinkphp 5 闭包函数的使用详解(传递参数)
普通使用
举个栗子:
$this->where(function ($query)
{
$query->where('id', 1)->whereor('id', 2);
})->find();
上述栗子就是一个简单的where查询的闭包函数使用,使用匿名函数添加...
php从数组中取出几个元素,数组分页
可以尝试使用 PHP 的 array_slice 函数:
array_slice 的功能是:从数组中取出一段。示例代码如下:
<?php
$input = array("a", "b", "c", "d", "e");
$output = array_slice($input, 2); // 输出...
thinkphp5 删除 destroy
删除当前模型
删除模型数据,可以在实例化后调用delete方法。
$user = User::get(1);
$user->delete();
根据主键删除
或者直接调用静态方法
User::destroy(1);
// 支持批量删除多个数据
User::destroy('1,2,3');
// 或者
User::destro...
thinkphp中怎么过滤html代码?
thinkphp模板显示中,怎样去掉内容中的链接?
{$val['content']|htmlspecialchars_decode|strip_tags}
这样就可以了
htmlspecialchars_decode() 函数把预定义的 HTML 实体转换为字符。
https://www.w3school.com...
thinkphp5分页paginate()出来的数据怎样循环插入数据?
paginate()出来的数据怎样循环插入数据?
paginate()分页如何转数组操作数据之后再转回对象?
thinkphp5 model里面用toarray后怎么分页?
以上类似问题的出现,是因为在model模型中使用了->paginate()分页,由于返回的是对象,所以要把数据转换到数组,才能在模...
thinkphp5 分页带参数的解决办法
利用tp5默认分页,搜索后点分页,又跑到原来列表了。怎么把搜索关键字传到分页里面呢?
$mrs = Db::name('log_operates')
->where($where)
->order('operateId', 'desc')
->paginate(input('pagesiz...
thinkphp5 怎么打印sql语句
thinkphp5打印最后一条执行的sql语句
echo db('table')->getlastsql();
db('table')不知道什么意思,不过貌似
db()->getlastsql();
db('123')->getlastsql();
$this->getlastsql();
这...
thinkPHP5 order多条件排序
总结如下:
//单一条件排序
$user = $this->where(['parentId'=>0)->field('userId,userName,userSort,isShow')->order('userSort', 'asc')->select();
//多个条件排序,可以多加一个order...
thinkPHP5 where多条件查询
总结如下:
//单一查询条件
$user = $this->where('userId',$userId)->field('secretKey,loginPwd')->find();
//多个查询条件,可以多加一个where
$user = $this->where('userId',$userId...
thinkphp5 select对象怎么转数组?
toArray() 为什么不行?
方法一:
DB操作返回是数组。模型直接操作返回是对象
对象类型转换数组
打开 database.php 增加或修改参数
'resultset_type' => '\think\Collection',
即可连贯操作
model('user')->select()-&...
thinkphp中根据ip获取国家省市
引入扩展文件
\extend\iplocation\Location.php
Location.php文件内容为:
<?php
/** .-------------------------------------------------------------------
* | Software: [Do...
php将字符串全部转换成大写或者小写
php中可以通过strtolower和strtoupper两个函数将字符串中的每个英文字符全部转换成小写或者大写
<?php
$string = "Learn PHP string functions at jb51.net";
$lower = strtolower($string);
$upper = strtouppe...
php中一个汉字占了用几个字符
对于标题字数的截取我们经常遇到,但是一般都是截取多少个汉字,代码里你设置的值都是字符。那么如何计算几个汉字限制几个字符呢。
其实这里是有区别的。因为这个和编码方式有关系。比如:
<?php echo strlen("新闻"); ?>
这里的输出的长度是6,那么一个汉字的字符长度就是3
可是如果你用gbk的方式 输出...
Declaration of app\home\model\Articles::getParent() should be compatible with think\Model::getParent()
Declaration of app\home\model\Articles::getParent() should be compatible with think\Model::getParent()
大概意思是:声明的app\home\model\Articles::getParent()方法应该与think\Model:...
关于本站
“最难不过坚持”
本人承接扒站仿站,php网站维护,病毒查杀,网站编辑,网站改版,html制作
有需要网站维护,改版,病毒查杀,网站编辑,网站备案,html制作等相关的工作可以联系我。
本人有多年相关工作经验,也可提供免费咨询,交个朋友。
有需要探讨问题的朋友,也可以加我微信,共同探讨!
微信:15011482830 QQ:408917339
2737
39
分类目录
最新评论
- https://jueru.net/
-
评 留言
- :weixiao:
-
评 留言
- :shuijiao: :weiqu: :zhenbang: :leng:
-
评 留言
- :yiwen: :yiwen: :yiwen: :yiwen:
-
评 EasySass: could not generate CSS file. See Output panel for details.
- 这个业务逻辑多少都有点奇怪了,阅读浏览次数增值在新闻详情页的控制器方法里setInc,这怎么还写进模型事件里了。如果非要用onAfterRead也可以,把新闻文章的内容单独分出来一个news_content表,然后把它和news做关联,然后给news_content表的onAfterRead事件做增值处理,这样点进新闻页内查询到文章内容时才会触发它。
-
评 TP6模型事件-查询后onAfterRead不好用
文章标签更多