note 96501 deleted from function.chmod by danbrown
| From: | danbrown@php.net | Date: | Tue, 02 Mar 2010 19:26:35 +0000 |
| Subject: | note 96501 deleted from function.chmod by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166539@lists.php.net to get a copy of this message | ||
Note Submitter: berglov at live dot com
----
Funny no one else have this problem written here.
I (And others I know) have hat problems getting this function to work when using strings as input.
The problem using INT, is that INT values will convert 0777 to 777 removing the starting 0. This
will change the input from octal to decimal, but the decimal value 777 is wrong. octal 0777 in
decimal should be 511.
So when the function does not work with strings, and you can't use octal as INT, then what to
do? Well, use the octdec() function, which can convert (string, octal) 0777 to (int, decimal) 511. A
value that the chmod DO understand perfectly.
chmod("file.php", octdec("0777"));
and if you don't trust this function
chmod("file.php", (int) octdec("0777"));