From fd2731cfce31eae7d14dfa8357f819bda8068d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Mon, 15 Apr 2013 15:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9B=BE=E7=89=87=E5=87=BA?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=B1=BB=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Think/Image.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Library/Think/Image.php b/Library/Think/Image.php index 2d59ebd5..90e837cb 100644 --- a/Library/Think/Image.php +++ b/Library/Think/Image.php @@ -43,22 +43,20 @@ class Image { private static $im; /** - * 构造方法,用于实例化一个图片处理对象 + * 初始化方法,用于实例化一个图片处理对象 * @param string $type 要使用的类库,默认使用GD库 */ - public function init($type = 'Gd', $imgname = null){ + static public function init($type = 'Gd', $imgname = null){ /* 引入处理库,实例化图片处理对象 */ - $class = '\\Think\\Image\\Driver\\'.ucwords($type); + $class = '\\Think\\Image\\Driver\\'.ucwords($type); self::$im = new $class($imgname); return self::$im; } // 调用驱动类的方法 static public function __callStatic($method, $params){ - if(empty(self::$im)) { - self::init(); - } - return call_user_func_array(array(self::$im, $method), $params); + self::$im || self::init(); + return call_user_func_array([self::$im, $method], $params); } } \ No newline at end of file