How does the chmod function differ from setting permissions directly in the mkdir function in PHP?
When creating a directory in PHP using the mkdir function, you can directly specify the permissions for the directory using the mode parameter. However, if you need to change the permissions of an existing directory, you would use the chmod function. The chmod function allows you to modify the permissions of a file or directory after it has been created.
// Create a directory with specific permissions using mkdir
$dir = 'new_directory';
$permissions = 0755; // Example permissions
mkdir($dir, $permissions);
// Change the permissions of an existing directory using chmod
$dir = 'existing_directory';
$permissions = 0755; // Example permissions
chmod($dir, $permissions);