Example analysis of mkdir function usage in php

  • 2021-07-26 07:18:43
  • OfStack

In this paper, the usage of mkdir function in php is analyzed with examples. Share it for your reference. The specific analysis is as follows:

mkdir () Syntax: bool mkdir (String Directory, Interpretation Permission) dirThe New directory. permissionsOctal number specifies permissions for new directory. Creates1 new directories.

mkdir () creates a directory with the specified permission to return true on success and FALSE if an error occurs, as the file schema () is the same as fileperms ().

The sample code for php is as follows:

<?php 
if (mkdir("temp", 0701)) 
   print " Directory created successfully ";
?>
//Output: Directory created successfully

Create a directory with full permissions

Explanation: mkdir () attempts to create a new directory specified by path.

The default mode is 0777, which means the maximum possible access.

Tips and Notes

Note: mode is ignored under Windows and is optional since PHP 4.2. 0. Support for context is added by PHP 5.0. 0, and recursive parameter is added by PHP 5.0. 0. The example code is as follows:

<?php mkdir("testing");?>

I hope this article is helpful to everyone's PHP programming.


Related articles: