通过phpinfo()获得GD库版本和MYSQL版本的方法

来源:互联网 发布:linux查看txt文件命令 编辑:程序博客网 时间:2024/04/29 15:29
  1. //--------------------------------
  2.     //获得GD的版本
  3.     //--------------------------------
  4.     function gdversion()
  5.     { 
  6.       static $gd_version_number = null; 
  7.       if ($gd_version_number === null)
  8.       { 
  9.         ob_start(); 
  10.         phpinfo(8); 
  11.         $module_info = ob_get_contents(); 
  12.         ob_end_clean(); 
  13.         if(preg_match("//bgd/s+version/b[^/d/n/r]+?([/d/.]+)/i"$module_info,$matches))
  14.         {   $gdversion_h = $matches[1];  }
  15.         else
  16.         {  $gdversion_h = 0; }
  17.       } 
  18.       return $gdversion_h;
  19.     }
  20.     //--------------------------------
  21.     //获得mysql的版本
  22.     //<td class="e">Client API version </td><td class="v">5.0.51a </td>
  23.     //--------------------------------
  24.     function mysqlversion()
  25.     { 
  26.       static $mysql_version_number = null; 
  27.       if ($mysql_version_number === null)
  28.       { 
  29.         ob_start(); 
  30.         phpinfo(8); 
  31.         $module_info = ob_get_contents(); 
  32.         ob_end_clean();
  33.         if(preg_match('/Client API version <//td><td class="v">([^<//td>]*)<//td>/i'$module_info,$matches))
  34.         {$mysqlversion_h = $matches[1];  }
  35.         else
  36.         {$mysqlversion_h = 0; }
  37.       } 
  38.       return $mysqlversion_h;
  39.     }