//参数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); }
开启错误提示代码:ini_set("display_errors", "On"); error_reporting(E_ALL | E_STRICT);关闭错误提示代码:error_reporting(E_ALL ^&n...
项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...
第一步:服务端文件<?php $wsdlfile='webservice.wsdl'; ini_set('soap.wsdl_cache_enabled','0'); //关闭WSDL缓存 //001...
PHP不像net支持多继承,自身只支持单继承,为了解决这个问题,php出了Trait这个特性,减少单继承语言的限制。并且能让代码复用率更高。说白了就是一个对象的属性和方法扩展工具一样。例如:trait exts { public f...
<?php $member = new class { public function getInfo() { ...
经常我们下载国外资源容易被墙,可以通过php脚本获取远程文件流然后输出给我们的浏览器来下载。<?php //设置下载文件的url $url = 'https://mirrors.huaweicloud.com/ubuntukylin/ubuntukylin-19....