判断远程图片是否存在,(即是否可访问,是否影应为200

    xiaoxiao2025-10-19  9

    function check_remote_file_exists($url) { $curl = curl_init($url); // 不取回数据 curl_setopt($curl, CURLOPT_NOBODY, true); // 发送请求 $result = curl_exec($curl); $found = false; // 如果请求没有发送失败 if ($result !== false) { // 再检查http响应码是否为200 $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($statusCode == 200) { $found = true; } } curl_close($curl); return $found; }
    转载请注明原文地址: https://ju.6miu.com/read-1303303.html
    最新回复(0)