热搜:NVER node 开发 php

PHP判断图片格式

2024-07-25 13:35:01
PHP判断图片格式

<?php

$imgurl  =  "http://finalshares.com/themes/site/biv_viva/images/logo.png" ;

//方法1

echo  $ext  =  strrchr ( $imgurl , '.' );

echo  '


' ;

//方法2

echo  $ext1  =  substr ( $imgurl , strrpos ( $imgurl ,  '.' ));

echo  '


' ;

//方法3

echo (@ end ( explode ( "." , $imgurl )));

echo  '


' ;

//方法4

echo  pathinfo ( $imgurl ,PATHINFO_EXTENSION);

print_r( pathinfo ( $imgurl ));

echo  '


' ;

//方法5

$imginfo =  getimagesize ( $imgurl );

print_r( $imginfo );

echo  end ( $imginfo );

echo  '


' ;

//方法6

$imghttp  = get_headers( $imgurl ,true);

print_r( $imghttp );

echo  '


' ;

//方法7

echo  exif_imagetype( $imgurl );