zoukankan      html  css  js  c++  java
  • 4-1验证码类封装之GD库验证

     1 <?php
     2 /**
     3  * GDBasic.php
     4  
     5  * description GD基础类
     6  */
     7 
     8 namespace ImoocLib;
     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 }
  • 相关阅读:
    Dynamics CRM9.0更新了Chrome后菜单按钮变形
    质量属性
    机器学习理解
    大道之简的理解
    架构之美理解
    1.13
    1.12
    1.11
    1.10
    Flex 替换输入的字符串
  • 原文地址:https://www.cnblogs.com/kay-learning/p/8973195.html
Copyright © 2011-2022 走看看