Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

umask()

Example

Retrieve the current umask.

<?php
$file = “test.txt”;
echo (umask());
?>

Definition and Usage

The umask() function sets the file creation mask to mask & 0777 and returns the previous umask.

Syntax

umask(mask)

Parameter Values

 

Parameter

Description

mask

Optional. Specifies the new permissions. Default is 0777

The mask parameter consists of four numbers:

  • The first number is always zero
  • The second number specifies permissions for the owner
  • The third number specifies permissions for the owner’s user group
  • The fourth number specifies permissions for everybody else

Possible values (to set multiple permissions, add up the following numbers):

  • 1 = execute permissions
  • 2 = write permissions

4 = read permissions

Technical Details

Return Value:

If you call umask() without arguments, it returns the current umask. If you provide a new umask, it sets that value and returns the previous umask.

PHP Version:

4.0+