What is umask in PHP

In this article I am going to explain about umask function in PHP.
  • 1495

PHP umask() Function

The filesystem umask function changes the file permission for files. The umask function without arguments simply returns the current umask otherwise the old umask is returned.

Syntax of umask function

umask(mask)

Parameters in umask function

It has only one parameter:

Parameter Description
mask It specifies the new permission.

Example of filesystem umask function

<html>

<body>

<?php

$old = umask(0);

chmod("dir.php", 0777);

$result=umask($old);

echo "The result is:" .$result;

if ($old != umask())

{

    die('An error occured !');

}

?>

</body>

</html>


Output:

umask-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.