Home > Article > Backend Development > php umask function tutorial_PHP tutorial
php umask function tutorial
umask value
(PHP 4, PHP 5)
umask - changes the current umask
Description
int umask ( [int $mask] )
umask() sets the PHP umask value to mask and 0777 and returns the old umask. When PHP is used as a server module, umask is restored when each request is completed.
Parameters
Mask
new umask.
Return value
umask value() without arguments returns only the current umask otherwise the old umask is returned.
Example
Example of umask() for example #1
$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');
}
?>