English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP umask() Function Usage and Example

PHP Filesystem Reference Manual

The umask() function sets PHP's umask to mask & 0777 And returns the original umask. When PHP is used as a server module, the umask is restored after each request.

Syntax

int umask ([ int $mask ] )

This function can set PHP's umask to mask & 0777And returns the original umask. When PHP is used as a server module, the umask is restored after each request.

 Calling umask() without parameters returns the current umask, and with parameters it returns the original umask.

Online Example

<?php
   $old = umask(0);
   chmod("PhpProject"/php/sample.txt", 0755);
   umask($old);
   //Check
   if($old != umask()) {
      echo "Error changing back umask";
   }
?>

PHP Filesystem Reference Manual