note 66172 added to function.umask

From: Date: Tue, 16 May 2006 16:32:35 +0000
Subject: note 66172 added to function.umask
Groups: php.notes 
Request: Send a blank email to php-notes+get-111389@lists.php.net to get a copy of this message
Notice that directory(s) and file(s) sometimes have different results. <?php umask(0670); //- set umask $handle = fopen('file', 'w'); //- 0006 mkdir("/path/dir"); //- 0107 ?> calculate the result: <?php $umask = 0670; umask($umask); //- if you are creating a new directory, $permission = 0777; //- if you are creating a new file, $permission = 0666. printf( "result: %04o", $permission & ( 0777 - $umask) ); ?> BTW, as the manual said, the form of umask() is "int umask ( [int mask] )", so if you want to print/echo any umask, don't forget to convert it from DEC (because it returns a "int") to OCT. <?php $umask = umask(); //- returns the current umask, which is a "int" $umask = decoct($umask); //- Now, $umask is a "string" echo $umask; ?> Don't forget that the argument(parameter) is a "int", too. <?php umask(777); //- WRONG! Even though you maybe use "umask 777" in some OS. umask(0777); //- OK ?> If there was any mistake, please correct my statement. ---- Server IP: 140.112.2.5 Probable Submitter: 218.168.118.45 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.umask.php Edit -- http://master.php.net/note/edit/66172 Del: integrated -- http://master.php.net/note/delete/66172/integrated Del: useless -- http://master.php.net/note/delete/66172/useless Del: bad code -- http://master.php.net/note/delete/66172/bad+code Del: spam -- http://master.php.net/note/delete/66172/spam Del: non-english -- http://master.php.net/note/delete/66172/non-english Del: in docs -- http://master.php.net/note/delete/66172/in+docs Del: other reasons-- http://master.php.net/note/delete/66172 Reject -- http://master.php.net/note/reject/66172 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#111389) next »