note 74721 added to function.fileperms

From: Date: Wed, 25 Apr 2007 04:43:44 +0000
Subject: note 74721 added to function.fileperms
Groups: php.notes 
Request: Send a blank email to php-notes+get-125847@lists.php.net to get a copy of this message
On Linux (not tested on Windows), if you want a chmod-like permissions, you can use this function: <?php function file_perms($file, $octal = false) { if(!file_exists($file)) return false; $perms = fileperms($file); $cut = $octal ? 2 : 3; return substr(decoct($perms), $cut); } ?> Using it: $ touch foo.bar $ chmod 0754 foo.bar <?php echo file_perms('foo.bar'); // prints: 754 echo file_perms('foo.bar', true); // prints 0754 ?> ---- Server IP: 200.185.109.13 Probable Submitter: 201.25.23.156 ---- Manual Page -- http://www.php.net/manual/en/function.fileperms.php Edit -- https://master.php.net/note/edit/74721 Del: integrated -- https://master.php.net/note/delete/74721/integrated Del: useless -- https://master.php.net/note/delete/74721/useless Del: bad code -- https://master.php.net/note/delete/74721/bad+code Del: spam -- https://master.php.net/note/delete/74721/spam Del: non-english -- https://master.php.net/note/delete/74721/non-english Del: in docs -- https://master.php.net/note/delete/74721/in+docs Del: other reasons-- https://master.php.net/note/delete/74721 Reject -- https://master.php.net/note/reject/74721 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125847) next »