The umask() function changes the file permissions for files.
This function sets PHP's umask to mask & 0777 and returns the old umask.
Calling umask() without any arguments returns the current umask.
PHP umask() Function has the following syntax.
umask(mask)
Parameter | Is required | Description |
---|---|---|
mask | Optional. | New permissions. Default is 0777 |
The mode parameter consists of four numbers:
Possible values (to set multiple permissions, add up the following numbers):
umask() without arguments simply returns the current umask otherwise the old umask is returned.
<?php//from ww w . j a v a 2 s. c o m
$old = umask(0);
chmod("test.txt", 0755);
umask($old);
// Checking
if ($old != umask()) {
die('An error occurred while changing back the umask');
}
?>