PHP判断图片格式的七种示例
内容摘要
这篇文章主要为大家详细介绍了PHP判断图片格式的七种示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!使用php判断文件图片的
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!使用php判断文件图片的
文章正文
这篇文章主要为大家详细介绍了PHP判断图片格式的七种示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随php教程的小玲来看看吧!
使用php判断文件图片的格式代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <code> <?php /* php教程 www.512Pic.com */ $imgurl = "https://www.idcnote.com/images/logo.gif" ; //方法1 echo $ext = strrchr ( $imgurl , '.' ); echo '<hr>' ; //方法2 echo $ext1 = substr ( $imgurl , strrpos ( $imgurl , '.' )); echo '<hr>' ; //方法3 echo (@ end ( explode ( "." , $imgurl ))); echo '<hr>' ; //方法4 echo pathinfo ( $imgurl ,PATHINFO_EXTENSION); print_r( pathinfo ( $imgurl )); echo '<hr>' ; //方法5 $imginfo = getimagesize ( $imgurl ); print_r( $imginfo ); echo end ( $imginfo ); echo '<hr>' ; //方法6 $imghttp = get_headers( $imgurl ,true); print_r( $imghttp ); echo '<hr>' ; //方法7 echo exif_imagetype( $imgurl ); </code> |
注:关于PHP判断图片格式的七种示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释