Home > Backend Development > PHP Tutorial > PHP directory creation function that supports multiple platforms_PHP tutorial

PHP directory creation function that supports multiple platforms_PHP tutorial

WBOY
Release: 2016-07-13 16:59:16
Original
978 people have browsed it

Support multi-platform PHP directory creation function We can specify which directory to create a directory in. /Get the directory name of the specified folder

Support multi-platform PHP tutorial directory creation function
We can specify which directory to create a directory in.
/Get the directory name of the specified folder

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                                // Generate a config.php file in the directory, of course this file can be defined by yourself
12                    if (!file_exists($dirpath.'/'.$value.'/'.$file))
13                                                                                                              14                     $fo = fopen($dirpath.'/'.$value.'/'.$file,'xb+'); //When I was here, I tried to use w+ before, but it failed,
15 // Under Windows, I have successfully created it, please pay attention! All suggestions are recommended to use XB+, compatible with multiple platforms
16                           chmod($file,"0777");
17                                                                                fwrite( $fo,'i is a zongzi ,here is config file!') or die('Failed to create the configuration file! Please check whether you have the operating permissions for this directory and file!');
18                         fclose($fo); 19           }
20                        $arr[] = $value;
21         }
22                                                                                  23             return $arr;
24 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631332.htmlTechArticleSupports multi-platform php directory creation function. We can specify which directory to create the directory in. / Get the directory name of the specified folder. Support multi-platform PHP tutorial directory creation function. We...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template