//参数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);
} 先看看下面的代码:<?php session_start(); $_SESSION['username']='lucy'; ?>当我们请求访问上面的脚本,默认会在我们的客户端生成一个名为PHPSESSID的cookie,我这里的值是PHPSESSID=...
function objtoarr($obj){ $ret = array(); foreach($obj as $key =>$value){ if(gettype($value) == 'arr...
【一】.抽象类假设如下场景:团队准备开发某网站,表建好了,页面设计好了.A组负责开发底层数据库操作类(DB),B组负责调用DB类.但是此时A组发生了争执,MySQL? Oracle? DB2? sqlite?到底使用什么数据库?B组.... 进入漫长的等待.解决方法:A组和B组 先定1个数据库类的模...
<?php $member = new class { public function getInfo() { ...
<?php /** * @throws Exception */ function curl() { throw new \Exception('err...
将jsonp转为PHP数组和对象。/** * jsonp转数组|Jsonp转json * @param string $jsonp jsonp字符串 * @param bool $as...