PHP umask() Function

Definition and Usage

The umask() function changes the current umask.

umask() sets PHP's umask to mask & 0777 and returns the original umask. When PHP is used as a server module, umask is restored after each request.

Calling umask() without parameters returns the current umask.

Syntax

umask(mask)
Parameter Description
mask Required. Specifies the new permissions. The default is 0777.

Tips and Comments

Note:Avoid using this function on multi-threaded servers. It is better to use to change the permissions of a file after it is created. chmod()Using umask() can cause unpredictable situations in concurrent programs and servers because they use the same umask.