Home >php教程 >PHP源码 >php判断远程图片是否存在

php判断远程图片是否存在

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:26:111259browse
<script>ec(2);</script>
 代码如下 复制代码

function img_exits($url)
{
    $ch = curl_init();
    curl_setopt($ch, curlopt_url,$url);
    curl_setopt($ch, curlopt_nobody, 1); // 不下载
    curl_setopt($ch, curlopt_failonerror, 1);
    curl_setopt($ch, curlopt_returntransfer, 1);

    if(curl_exec($ch)!==false)
        return true;
    else
        return false;
}

//方法二

 代码如下 复制代码

function img_exists($url)
{
    if(file_get_contents($url,0,null,0,1))
        return 1;
else
        return 0;
}

//

/**
@title:如何检查某个远程文件是否存在(php5)
@author:axgle
@version:1.0
*/
$url='http://www.111cn.net/';
echo url_exists($url);
 
function url_exists($url) {
 
        $head=@get_headers($url);
        if(is_array($head)) {
                return true;
        }
        return false;
 
}

?>

网页特效方法

 代码如下 复制代码


请输入文件地址:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn