PHP umask() Function

P
PHP unlink() Function
PHP touch() Function

In this article, you will learn how to change the file permission in PHP. The umask() function in PHP changes the file permissions for files. This function returns the old mask and set the new umask to mask & 0777.

what is the syntax of the UMASK function in php?

umask(mask)
ParameterDescription
maskOptional. Specifies the new permissions. Default is 0777The mask parameter consists of four numbers:The first number is always zeroThe second number specifies permissions for the ownerThe third number specifies permissions for the owner’s user groupThe fourth number specifies permissions for everybody elsePossible values (to set multiple permissions, add up the following numbers):1 = execute permissions2 = write permissions4 = read permissions
PHP umask() method

examples of the UMASK function

Example 1. In this example, we return the current umask.

<?php
$file = "test.txt";
echo (umask());
?>
PHP unlink() Function
PHP touch() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z