首页 > php基础 > 支持多平台的php目录创建函数

支持多平台的php目录创建函数

支持多平台的php目录创建函数
我们可以指定在那个目录下创建目录哦。
/取得指定文件夹的目录名称

支持多平台的php教程目录创建函数
我们可以指定在那个目录下创建目录哦。
/取得指定文件夹的目录名称

 2         function get_dir_name($dir_path,$file)
 3         {
 4             $dirpath = $dir_path;
 5             $dir = scandir($dirpath);
 6             foreach ($dir as $key=>$value)
 7             {
 8                 if (is_dir($dirpath.'/'.$value) && $value != '.' && $value != '..')
 9                 {
10                     //echo $dirpath.'/'.$value.'/'.$file;                    
11                     //在目录下生成一个config.php文件,当然这个文件可以自己定义了
12                     if (!file_exists($dirpath.'/'.$value.'/'.$file))
13                     {                                                
14                         $fo = fopen($dirpath.'/'.$value.'/'.$file,'xb+');    //在这里的时候,我之前尝试用w+,结果失败,
15                         //在windows 下,我有创建成功,请注意了!所有建议用xb+,兼容多平台
16                         chmod($file,"0777");
17                         fwrite( $fo,'i is a zongzi ,here is config file!') or die('配置文件创建失败!请检查是否有此目录和文件的操作权限!');
18                         fclose($fo);                                                                        
19                     }
20                     $arr[] = $value;
21                 }
22             }        
23             return $arr;
24         }

文章地址:http://www.phprm.com/base/39477.html

转载随意^^请带上本文地址!

标签:fopen

相关文章

发表留言