自动检测GD库支持的图像类型

以下代码通过自动检测GD库支持的图像类型 来写出移直性更好的PHP代码

 1 <?php
 2             if(function_exists("imagegif")){
 3                 header("Content-type : image/gif");
 4                 imagegif($image);
 5             }elseif(function_exists("imagepng")){
 6                 header("Content-type : image/png");
 7                 imagepng($image);
 8             }elseif(function_exists("imagejpeg")){
 9                 header("Content-type : image/jpeg");
10                 imagejpeg($image);
11             }elseif(function_exists("imagewbmp")){
12                 header("Content-type : image/wbmp");
13                 imagewbmp($image);
14             }else{
15                 die("在PHP服务器中,不支持图像");
16             }
17         ?>
检测GD库支持的图像类型
原文地址:https://www.cnblogs.com/banshaohuan/p/4987518.html