Home  >  Article  >  Backend Development  >  PHP code to create multi-level directories

PHP code to create multi-level directories

WBOY
WBOYOriginal
2016-07-25 08:45:32989browse
  1. function create_dir($path,$mode)
  2. {
  3. if (is_dir($path)){ //Determine whether the directory exists, if it exists, do not create it
  4. echo "Directory'" . $path . "'already exists" ;
  5. }
  6. else
  7. { //There is no creation
  8. $re=mkdir($path,$mode,true); //The third parameter is true to create a multi-pole directory
  9. if ($re){
  10. echo "Directory creation successful";
  11. }else{
  12. echo "Directory creation failed";
  13. }
  14. }
  15. }
  16. $path="aa/bb/cc/cd"; //The directory to be created
  17. $mode=0755; //Create directory mode
  18. create_dir($path,$mode);//Test
Copy code

php


Statement:
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