Home >Backend Development >PHP Tutorial >PHP判断图片格式的七种方法

PHP判断图片格式的七种方法

WBOY
WBOYOriginal
2016-06-20 12:38:101004browse

<?php $imgurl = "http://finalshares.com/themes/site/biv_viva/images/logo.png"; //方法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);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn