September 2001
Intermediate to advanced
768 pages
32h 45m
English
int umask([int mask]) Changes PHP’s umask.
Returns:
Current or old umask
Description:
umask() controls the permissions with which new files are created. The default mask is 0777; after the call to umask() it will be mask & 0777.
If umask() is called without any arguments, the current umask is returned. If PHP is compiled as a module, when a page request has terminated the default umask is restored.
This mask can be difficult to understand for new UNIX users; some practice may be required. Try the example and notice how permissions have been modified.
Example:
<?php
touch ("/tmp/umask-test-before");
umask (20);
touch ("/tmp/umask-test-after");
echo `ls -l /tmp/umask-test-*`;
?>
Output: -rw-r---w- 1 nobody nogroup 0 ... |
Read now
Unlock full access