Home >Backend Development >PHP Tutorial >PHP multiple judgment delete file function code

PHP multiple judgment delete file function code

WBOY
WBOYOriginal
2016-07-25 08:55:411004browse
  1. /**
  2. * func: delete_file
  3. * params: $file file name
  4. * Multiple conditional judgment to delete file
  5. * by bbs.it-home.org
  6. */
  7. function delete_file($file)
  8. {
  9. if (file_exists($file))
  10. {
  11. $delete = chmod ($file, 0777);
  12. $delete = unlink($file);
  13. if(file_exists($file))
  14. {
  15. $filesys = eregi_replace("/","\",$file);
  16. $delete = system("del $filesys");
  17. clearstatcache();
  18. if(file_exists($file))
  19. {
  20. $delete = chmod ($file, 0777);
  21. $delete = unlink($file);
  22. $delete = system("del $filesys");
  23. }
  24. }
  25. clearstatcache();
  26. if(file_exists($file))
  27. {
  28. return 'Delete Faile : '.$file.'
    ';
  29. }
  30. else
  31. {
  32. return 'Delete Successs : '.$file.'
    ';
  33. }
  34. }
  35. else
  36. {
  37. return 'Delete Successs : '.$file.'
    ';
  38. }
  39. }
  40. ?>
复制代码


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