# GÓC SÁNG TẠO > Khu vực lập trình > Mã nguồn mở >  [php] function create folder in linux | window server

## diamondlotusvn.com

```

[COLOR=#000000][/COLOR][COLOR=#FF8000]/* function create folder in linux | window server  * @param $path  * @param $mode  * author: tu.nguyenhoang  */    [/COLOR][COLOR=#007700]function [/COLOR][COLOR=#0000BB]rmkdir[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$path[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]$mode [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]0777[/COLOR][COLOR=#007700]) {  [/COLOR][COLOR=#0000BB]define[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]'DS'[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]DIRECTORY_SEPARATOR[/COLOR][COLOR=#007700]);     [/COLOR][COLOR=#0000BB]$dirs [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]explode[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]DS[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000BB]$path[/COLOR][COLOR=#007700]);     [/COLOR][COLOR=#0000BB]$countDir [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]count[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$dirs[/COLOR][COLOR=#007700]) - (([/COLOR][COLOR=#0000BB]strrpos[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$path[/COLOR][COLOR=#007700], [/COLOR][COLOR=#DD0000]"."[/COLOR][COLOR=#007700])===[/COLOR][COLOR=#0000BB]false[/COLOR][COLOR=#007700]) ? [/COLOR][COLOR=#0000BB]0 [/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]);     for ([/COLOR][COLOR=#0000BB]$i[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$i [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000BB]$countDir [/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$i[/COLOR][COLOR=#007700]++) {         [/COLOR][COLOR=#0000BB]$truepath[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#DD0000]""[/COLOR][COLOR=#007700];         for ([/COLOR][COLOR=#0000BB]$k[/COLOR][COLOR=#007700]=[/COLOR][COLOR=#0000BB]0[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$k [/COLOR][COLOR=#007700]<= [/COLOR][COLOR=#0000BB]$i[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000BB]$k[/COLOR][COLOR=#007700]++) {             [/COLOR][COLOR=#0000BB]$truepath [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000BB]$dirs[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]$k[/COLOR][COLOR=#007700]] . [/COLOR][COLOR=#0000BB]DS[/COLOR][COLOR=#007700];         }         if (![/COLOR][COLOR=#0000BB]file_exists[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$truepath[/COLOR][COLOR=#007700])) {          @[/COLOR][COLOR=#0000BB]opendir[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$truepath[/COLOR][COLOR=#007700]); [/COLOR][COLOR=#FF8000]// fix SAFE MODE Restriction in effect.             [/COLOR][COLOR=#0000BB]mkdir[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$truepath[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000BB]$mode[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]true[/COLOR][COLOR=#007700]);         }     } }[/COLOR] 


```

----------

