note 96501 added to function.chmod

From: Date: Tue, 02 Mar 2010 19:22:45 +0000
Subject: note 96501 added to function.chmod
Groups: php.notes 
Request: Send a blank email to php-notes+get-166538@lists.php.net to get a copy of this message
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")); ---- Server IP: 87.54.44.10 Probable Submitter: 90.185.169.141 ---- Manual Page -- http://www.php.net/manual/en/function.chmod.php Edit -- https://master.php.net/note/edit/96501 Del: integrated -- https://master.php.net/note/delete/96501/integrated Del: useless -- https://master.php.net/note/delete/96501/useless Del: bad code -- https://master.php.net/note/delete/96501/bad+code Del: spam -- https://master.php.net/note/delete/96501/spam Del: non-english -- https://master.php.net/note/delete/96501/non-english Del: in docs -- https://master.php.net/note/delete/96501/in+docs Del: other reasons-- https://master.php.net/note/delete/96501 Reject -- https://master.php.net/note/reject/96501 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166538) next »