DeTechn Blog

PHP高效判断远程图片是否存在

<?php
function remoteImageExist($url)
{
    // $exif_imagetype = [
    //     1 => 'GIF',
    //     2 => 'JPG',
    //     3 => 'PNG',
    //     4 => 'SWF',
    //     5 => 'PSD',
    //     6 => 'BMP',
    //     7 => 'TIFF(intel byte order)',
    //     8 => 'TIFF(motorola byte order)',
    //     9 => 'JPC',
    //     10 => 'JP2',
    //     11 => 'JPX',
    //     12 => 'JB2',
    //     13 => 'SWC',
    //     14 => 'IFF',
    //     15 => 'WBMP',
    //     16 => 'XBM'
    // ];
    $isExsit&nbsp;=&nbsp;@exif_imagetype($url);
    if ($isExsit === false) return false;
    return in_array($isExsit, [1, 2, 3]) ? true : false;
}
$url = 'https://detechn.image.alimmdn.com/blog/logo.png?t=1492719500597';;
remoteImageExist($url);
?>

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »