file_exists ( string filename)
解决方案 »
- 有想练手的吗。谁可以帮我把这个javascript函数转成php的呀。
- 搜索页面URL,补全默认关键字
- php基础问题,一点就通。
- DvBBS 7.x Access => Discuz!5.0.0 转换 ---出错!!!!!!!!
- 求助:论坛附件不能下载
- 服务器集群问题
- 怎么设置require和include调用文件的地址?我怎么到报错。。。向各位大哥求助!
- 请问PHP怎样根据一个域名去获得他的IP地址?就像dos下的ping的功能?
- 帮我看看是什么出错,好吗?Fatal error: Maximum execution time of 30 seconds exceeded in G:\supermarket\SearchHeTong.php on line 186
- php添加扩展 在phpinfo能看到该扩展,但在cli用php -m 却看不到,为什么呢
- 为什么图片显示不出来?
- 关于获取地址,在线等,100分.
function remote_file_exists($url) { // similar to file_exists(), checks existence of remote files
$url = trim($url);
if (!preg_match("=://=", $url)) $url = "http://$url";
if (!($url = @parse_url($url))) {
return false;
}
if (!eregi("http", $url['scheme'])) {
return false;
}
$url['port'] = (!isset($url['port'])) ? 80 : $url['port'];
$url['path'] = (!isset($url['path'])) ? "/" : $url['path'];
$fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
if (!$fp) {
return false;
}
else {
$head = "";
$httpRequest = "HEAD ".$url['path']." HTTP/1.1\r\n"
."HOST: ".$url['host']."\r\n"
."Connection: close\r\n\r\n";
fputs($fp, $httpRequest);
while (!feof($fp)) {
$head .= fgets($fp, 1024);
}
fclose($fp); preg_match("=^(HTTP/\d+\.\d+) (\d{3}) ([^\r\n]*)=", $head, $matches);
if ($matches[2] == 200) {
return true;
}
}
}