//参数1 文件名 参数2 缩放比例 function _thumb($_filename,$_percent){ ob_clean(); //生成png标头文件 header('Content-type:image/png'); $_n=explode('.', $_filename); //获取文件的信息,宽和高 list($_width,$_height)=getimagesize($_filename); //生成缩略后的大小 $_new_width=$_width*$_percent; $_new_height=$_height*$_percent; //按照新的大小创建微缩画布 $_new_image=imagecreatetruecolor($_new_width, $_new_height); //按照已经有的图片创建一个画布[按照图片类型] switch($_n[1]){ case 'jpg':$_image=imagecreatefromjpeg($_filename); break; case 'png':$_image=imagecreatefrompng($_filename); break; case 'gif':$_image=imagecreatefromgif($_filename); break; } //将原来的图复制到新的图片上 imagecopyresampled($_new_image, $_image, 0, 0, 0, 0, $_new_width, $_new_height, $_width, $_height); //输出图片 imagepng($_new_image); //销毁新资源句柄 imagedestroy($_new_image); //销毁原资源句柄 imagedestroy($_image); }
前公司吃饭是需要在钉钉报餐的,对于不挑剔的我每天都在公司吃饭,有时忘记报餐导致吃不了饭还是很麻烦的。看了下报餐系统需要的是json数据包含我的工号即可。于是编写如下代码,放在360网址监控,1小时执行1次<?php /*自动报餐类*/ class AutoBaocan{...
原理:使用curl_init()创建多个请求实例,再使用curl_multi_init()批量执行创建的多个请求实例。文件1:curl.php<?php $threads=500;//并发请求次数 $url='http://blog.cn/index.php?';...
逛公众号文章看到文章"php实现事件监听与触发的方法,你用过吗?",我就好奇了,php又不是asp.net的webform,哪里来的服务端事件监听。于是学习了一波。先看下监听类:class Event { /** &nbs...
Redis提供了发布订阅功能,可以用于消息的传输,Redis的发布订阅机制包括三个部分,发布者(publisher),订阅者(subscriber)和频道(channel)。 发布者和订阅者都是Redis客户端,Channel则为Redis服务器端,发布者将消息发送到某个的频道,订阅了这个...
(1)swoole启动的主进程是master进程负责全局管理,然后master进程会再fork一个manager进程。(2)manager进程开始统一管理进程创建回收管理。(3)manager进程根据设置的worker_num和task_worker_num来创建work进程和task进程因此启动s...
最近在编写windows php多线程的东西,从官网下载了PHP的线程安全版,尝试开启curl扩展extension=php_curl.dllphp -m 却提示 PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl...