What is the best practice for creating folders in PHP using the mkdir function?

When creating folders in PHP using the mkdir function, it is important to ensure that the correct permissions are set for the newly created folder. This will prevent any potential issues with file access or modification. To do this, you can specify the desired permissions as the second parameter in the mkdir function call.

// Create a new folder with the specified permissions
$folderPath = 'path/to/new/folder';
$permissions = 0777; // Set the desired permissions for the new folder
mkdir($folderPath, $permissions);