PHP umask()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

The umask() function changes the file permissions of a file.

This function sets PHP's umask tomask& 0777 and returns the previous umask. However, if you call umask() without parameters, it returns the current umask.

Syntax

umask(mask)

Parameters Description
mask Optional. Specifies the new permission. Default is 0777.

The mask parameter consists of four numbers:

  • The first number is usually 0
  • The second number specifies the permissions for the owner
  • The third number specifies the permissions for the user group to which the owner belongs
  • The fourth number specifies the permissions for all other users

Possible values (to set multiple permissions, add the following numbers together):

  • 1 = Execute permission
  • 2 = Write permission
  • 4 = Read permission


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions