Home > Article > Backend Development > Tips on using mkdir function in PHP
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!