- function check_img_by_source($source) {
-
- switch(bin2hex(substr($source,0,2))){
- case 'ffd8' : return 'ffd9' === bin2hex(substr($source,-2)); //jpg
- case '8950' : return '6082' === bin2hex(substr($source,-2)); //png
- case '4749' : return '003b' === bin2hex(substr($source,-2)); //gif
- default : return false;
- }
- }
分享根据二进制数据判断图片格式的代码
最新推荐文章于 2023-10-23 10:16:50 发布