umask
Changes the current umask
Description
int umask(intnull $mask
= null
)
Parameters
-
mask
-
The new umask.
Return Values
If mask
is null
, umask
simply returns the current umask otherwise the old umask is returned.
Examples
Example #1 umask example
<?php
$old = umask(0);
chmod("/path/some_dir/some_file.txt", 0755);
umask($old);
// Checking
if ($old != umask()) {
die('An error occurred while changing back the umask');
}
?>
Notes
Note:
Avoid using this function in multithreaded webservers. It is better to
change the file permissions with chmod after
creating the file. Using umask can lead to
unexpected behavior of concurrently running scripts and the webserver
itself because they all use the same umask.