zoukankan      html  css  js  c++  java
  • php文件删除unlink()详解

    请记住从PHP文件创建的教训,我们创建了一个文件,名为testFile.txt 。
    $myFile = "testFile.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fclose($fh);
    判断是否删除了. http://www.manongjc.com/article/1351.html
    $myFile = "testFile.txt";
    unlink($myFile);

    $filename = 'file.txt';
    fopen($filename,'a+');
    if(!unlink($filename))
    {
    echo "文件{$filename}删除失败"; //  http://www.manongjc.com/article/1351.html
    }
    else
    {
    echo "文件{$filename}删除成功";
    }
    ?>
    删除目录下所有文件
    function delFileUnderDir( $dirName="../Smarty/templates/templates_c" )
    {
    // http://www.manongjc.com/article/1351.html
    if ( $handle = opendir( "$dirName" ) ) {
       while ( false !== ( $item = readdir( $handle ) ) ) {
       if ( $item != "." && $item != ".." ) {
       if ( is_dir( "$dirName/$item" ) ) {
             delFileUnderDir( "$dirName/$item" );
       } else {
       if( unlink( "$dirName/$item" ) )echo "成功删除文件: $dirName/$item<br />n";
       }
       }
       }
       closedir( $handle );
    }
    }

  • 相关阅读:
    对bootstrap不同版本的总结
    对于前后端分离的理解
    css3笔记
    Dom
    js菜单
    css兼容问题 ie6,7
    html知识
    前端基础知识
    前端要注意的代码规范
    bootstrap常见类的总结
  • 原文地址:https://www.cnblogs.com/myhomepages/p/6010033.html
Copyright © 2011-2022 走看看