PHP Function Umask
php function umask is used to control the permissions which are applied by default when new files are created. The mask can be set in either octal or decimal form. It can also be padded with zeros in order to create an octal value. It is important to remember that umask only revokes permissions; it does not grant them. This means that you will still need to use chmod to grant any additional permissions that are required.
Each process has its own mask which is applied whenever it creates a file. Any process spawned from the shell inherits the mask of the shell. This means that if you umask(22) then the mask will be applied to all processes spawned by that shell, which will cause them to have 0666 permissions on all new files that they create (this can be dangerous).
Any additional masks that are applied should be remembered as they will only apply for that shell session. This means that when you restart your shell or log in again any new files or directories will be given the default permissions as chosen by your distribution (usually 002). If you use a more restrictive umask then it is recommended that you follow this with a call to chmod() to manually set the permissions on each file or directory. Otherwise you may find that your applications do not work properly. This is why the safest place to store a custom umask is in your