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

WBOY
Release: 2016-06-20 13:04:07
Original
934 people have browsed it

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 />}
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!