/* * 判断图片是否为动态图片(动画) */ function isAnimatedGif($filename) { $fp=fopen($filename,'rb'); $filecontent=fread($fp,filesize($filename)); fclose($fp); return strpos($filecontent,chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0')===FALSE?0:1; }
<?php function IsAnimatedGif($filename) { $fp = fopen($filename, 'rb'); $filecontent = fread($fp, filesize($filename)); fclose($fp); return strpos($filecontent,chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0') === FALSE?0:1; } echo IsAnimatedGif("51windows.gif"); ?>
<?php function check($image){ $content= file_get_contents($image); if(preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$content)){ return true; }else{ return false; } } if(check('/home/lyy/luoyinyou/2.gif')){ echo'真是动画'; }else{ echo'不是动画'; } ?>
希望本文所述对大家的PHP程序设计有所帮助。