Create a Directory in PHP
PHP provides a number of functions that can be used to perform tasks such as identifying and changing the current directory, creating new directories, deleting existing directories, and listing the contents of a directory. So, in this article, we will see how to create a directory in PHP.
To create a directory, we need to use mkdir() function. This function tasks a path to the directory to be created. To create a directory within the same directory, the PHP script simply provides the directory name. To create a new directory in a different directory specify the full path by calling mkdir() function. A second, optional argument allows the specification of permissions on the directory.
<?php $result = mkdir("/tmp/bin", "777"); ?>
Note: Each file/directory is associated with 3 permission rights-RMX (Read-write Execute) in which each right is represented by 3 bits- Here first bit corresponds to the owner, the second bit corresponds to the group and the third bit corresponds to others. For each file/directory, there will be 9 bits. If all in one, it is corresponding to decimal 7. So, 777 means all rights are given to all members who want to access that file/directory.
Read more: create table in PHP