Home  >  Article  >  Backend Development  >  Tips on using mkdir function in PHP

Tips on using mkdir function in PHP

墨辰丷
墨辰丷Original
2018-06-05 16:26:471587browse

This article mainly introduces the usage skills of mkdir function in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

The sample code is as follows:

<?php
  header("Content-type:text/html;charset=utf-8");
  //要创建的多级目录
  $path="dai/php/php学习";
  //判断目录存在否,存在给出提示,不存在则创建目录
  if (is_dir($path)){ 
    echo "对不起!目录 " . $path . " 已经存在!";
  }else{
    //第三个参数是“true”表示能创建多级目录,iconv防止中文目录乱码
    $res=mkdir(iconv("UTF-8", "GBK", $path),0777,true); 
    if ($res){
      echo "目录 $path 创建成功";
    }else{
      echo "目录 $path 创建失败";
    }
  }
?>

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's learning.

Related recommendations:

Sharing examples of how PHP can implement the function of changing avatars for multiple users

PHP simply implements member retrieval of passwords Functional method

#Method of implementing SMS verification code interface based on PHP

The above is the detailed content of Tips on using mkdir function in PHP. For more information, please follow other related articles on the PHP Chinese website!

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