umask
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Changes the current umask
Description
umask(int|null $mask = null): int
umask() sets PHP's umask to mask & 0777 and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished.
Parameters
maskThe new umask.
Return Values
If mask is null, umask() simply returns the current umask otherwise the old umask is returned.
Changelog
| Version | Description |
|---|---|
| 8.0.0 | mask is nullable now. |
Examples
umask() example
php
<?php
$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');
}
?>