日期:2011-11-03  浏览次数:20352 次

PHP判断文件是否存在,可使用如下代码:

  1. //判断远程文件是否存在  
  2. function remote_file_exists($url) {  
  3.     $executeTime = ini_get('max_execution_time');  
  4.     ini_set('max_execution_time', 0);  
  5.     $headers = @get_headers($url);  
  6.     ini_set('max_execution_time'$executeTime);  
  7.     if ($headers) {  
  8.         $head = explode(' '$headers[0]);  
  9.         if (!emptyempty($head[1]) && intval($head[1]) < 400) return true;  
  10.     }  
  11.     return false;  
  12. }