Menu Home

umask

osbo.com | PHP | Functions | umask

Changes the current umask

Syntax

umask ([ int $mask ] ) : int

Parameters

mask

The new umask.

Return

umask() without arguments simply returns the current umask otherwise the old umask is returned.

Examples

<?

$old = umask(0);
printf("%04o\n", $old);

$filename = "myfile.txt";
chmod($filename, 0755);

$return = umask($old);
printf("%04o\n", $return);

$current = umask();
printf("%04o\n", $current);

if ($old != $current) {
    die('An error occurred while changing back the umask');
}

?>
0022
0000
0022

PHP