Home  >  Article  >  Backend Development  >  php判断远程文件是否存在的方法

php判断远程文件是否存在的方法

WBOY
WBOYOriginal
2016-06-20 13:04:07918browse

php如何判断一个远程文件是否存在呢?

下面是作者在网上找到的方法,在这里和大家分享一下。

<p>//php判断远程文件是否存在</p>function url_exists($url){<br />    $handle=curl_init($url);<br />    if(false===$handle){<br />		return false;<br />    }<br />    curl_setopt($handle,CURLOPT_HEADER,false);<br />    curl_setopt($handle,CURLOPT_FAILONERROR,true);<br />    curl_setopt($handle,CURLOPT_NOBODY,true);<br />    curl_setopt($handle,CURLOPT_RETURNTRANSFER,false);<br />    $connectable=curl_exec($handle);<br />	//http://www.scutephp.com/<br />    curl_close($handle);    <br />    return $connectable;<br />}


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