首页 > 其他 > 详细

4-1验证码类封装之GD库验证

时间:2018-04-30 12:48:06      阅读:212      评论:0      收藏:0      [点我收藏+]
 1 <?php
 2 /**
 3  * GDBasic.php
 4  
 5  * description GD基础类
 6  */
 7 
 8 namespace Imooc\Lib;
 9 
10 
11 class GDBasic
12 {
13     protected static $_check =false;
14 
15     //检查服务器环境中gd库
16     public static function check()
17     {
18         //当静态变量不为false
19         if(static::$_check)
20         {
21             return true;
22         }
23 
24         //检查gd库是否加载
25         if(!function_exists("gd_info"))
26         {
27             throw new \Exception(‘GD is not exists‘);
28         }
29 
30         //检查gd库版本
31         $version = ‘‘;
32         $info = gd_info();
33         if(preg_match("/\\d+\\.\\d+(?:\\.\\d+)?/", $info["GD Version"], $matches))
34         {
35             $version = $matches[0];
36         }
37 
38         //当gd库版本小于2.0.1
39         if(!version_compare($version,‘2.0.1‘,‘>=‘))
40         {
41             throw new \Exception("GD requires GD version ‘2.0.1‘ or greater, you have " . $version);
42         }
43 
44         self::$_check = true;
45         return self::$_check;
46     }
47 }

 

4-1验证码类封装之GD库验证

原文:https://www.cnblogs.com/kay-learning/p/8973195.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!