mkdir

bool mkdir(string dir, int mode) 

Creates a directory.

Returns:

TRUE on success; FALSE on failure

Description:

Creates a directory with permissions as specified by the umask. The function returns an error if directory creation failed due to safe mode being in effect or permission problems. Note that you probably want to specify the mode as an octal number, so it should have a leading zero.

Example:

Create a new directory
$path = "/home/user/newdir"; 

if(!mkdir($path, 0700)) 
{
    echo ("Couldn't create directory"); 
} 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.