PHP.nl

umask

umask

Changes the current umask

int **umask**  $mask
sets PHP's umask to
& 0777 and returns the old

umask. When PHP is being used as a server module, the umask is restored when each request is finished. umask``mask

maskThe new umask.

If is null,
simply returns the current umask otherwise the old umask is returned. mask``umask

Voorbeeld: example

<?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');
}
?>

Opmerking: > Avoid using this function in multithreaded webservers. It is better to change the file permissions with after creating the file. Using can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask. chmod``umask