zoukankan      html  css  js  c++  java
  • 【PHP】文件转移

    今天看到一段经典代码,感觉太厉害了

    function recurse_copy( $src , $dst ){
         $handle = opendir( $src );
         @mkdir( $dst );
         while( false !== ( $file = readdir( $handle ) ) )
         {
             if( ( $file != '.' ) && ( $file != '..' ) )
             {
                 if( is_dir( $src . '/' . $file ) )
                 {
                     recurse_copy( $src . '/' . $file, $dst . '/' . $file );
                 }
                 else
                 {
                     copy( $src . '/' . $file, $dst . '/' . $file );
                 }
             }
         }
         closedir( $handle );
     }
    recurse_copy( $src , $dst )
    $src原有目录,$dst现有目录

    2017年11月29日10:39:38 

    昨天工作中遇到问题,mkdir不起作用,百思不得其解,最后找到原因:

    @mkdir( $dst );中参数只有pathname,而还有两个参数至关重要,第二个参数:默认的 mode 是 0777,意味着最大访问权限,
    第三个参数:recursive:
    Allows the creation of nested directories specified in the pathname.中文解释:允许嵌套目录中指定的路径创造。 看到解释是不很直观明了
    所以当我加上另外两个参数时,就执行成功@mkdir( $dst,0777,true );
  • 相关阅读:
    feign远程调用问题
    java8--stream
    feign业务组件远程请求 /oauth/token
    redis实现自增序列
    MySQL数据库 相关知识点
    netty
    spring的启动流程及bean的生命周期
    MethodHandleVS反射
    并发与并行
    关于注解的思考
  • 原文地址:https://www.cnblogs.com/Horsonce/p/7889364.html
Copyright © 2011-2022 走看看