PHP判断文件是否存在

原创
2016-06-21 08:52:06 1366浏览

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]) return true;
  10. }
  11. return false;
  12. }



声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。