简单判断远程资源是否存在

      发布在:后端技术      评论:0 条评论
//判断远程资源是否存在
function resource_exists($url){
$res =get_headers( $url );
$statusCode = substr ( $res[0], 9, 3);
if ( $statusCode == 200 ||  $statusCode == 304){
//        存在
       return true;
} else {
//        不存在
       return false;
}
}


相关文章
热门推荐