What is the default mode for mkdir() in PHP and why is it important to specify it?
By default, the mkdir() function in PHP creates a directory with permissions set based on the system's umask. It is important to specify the mode parameter when using mkdir() to ensure that the directory is created with the correct permissions for your specific use case. This can help prevent security vulnerabilities or permission issues in your application.
<?php
$dir = 'new_directory';
$mode = 0777; // Specify the desired permissions here
if (!file_exists($dir)) {
mkdir($dir, $mode, true);
}
?>