What function in PHP can be used to create a folder?

To create a folder in PHP, you can use the mkdir() function. This function takes two arguments: the directory path you want to create and optional permissions for the new directory. Make sure you have the necessary permissions to create folders on the server. After calling mkdir(), you can check if the folder was successfully created using the return value of the function.

$folderPath = 'path/to/new/folder';
$permissions = 0777; // optional permissions
if (!file_exists($folderPath)) {
    if(mkdir($folderPath, $permissions, true)) {
        echo "Folder created successfully.";
    } else {
        echo "Failed to create folder.";
    }
} else {
    echo "Folder already exists.";
}