- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
mkdir() function in PHP
The mkdir() function is used to create a new directory.
Syntax
mkdir(file_path,mode,recursive,context)
Parameters
file_path − Path of the directory you want to create.
mode − Specify permission.
Set the mode with the following four values.
- zero
- permission for owner
- permission for the owner’s user group
- permissions for rest
The following are the values to set multiple permissions. You need to add the following numbers −
- 1 = execute permissions
- 2 = write permissions
- 4 = read permissions
recursive − Set recursive mode
context − The context of the file handle.
Return
The mkdir() function returns TRUE on success and FALSE on failure.
The following is an example that creates a new directory. This sets the default mode 0777.
Example
<?php mkdir("testing"); ?>
The above code creates a directory “testing.
Let us see another example that creates a new directory and sets the mode as well.
Example
<?php mkdir("QA", 0700); ?>
Advertisements
To Continue Learning Please Login
Login with Google