PHP code to create multi-level directories

WBOY
Release: 2016-07-25 08:45:32
Original
989 people have browsed it
  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


Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!