On 02 August 2007 15:58, Daniel Brown wrote: > On 8/2/07, Ben Ramsey <ramsey@xxxxxxx> wrote: > > I'm trying to set a sticky bit on a directory with chmod(). The same > > octal value works from the command prompt, but it doesn't appear to > > work correctly with the PHP function. Anyone have an idea as to why? [SNIP] > Drop the preceding 0 from the chmod() function parameters. The > four-digit octal value is preferred, and the 0 is the first bit to > show that there's no user- or group-specific execution (su-exec'ing, > basically) or "stickiness" to the file/directory. However, > three-digit values will work. In either case, five digits will not > work. That's a ridiculous and downright wrong piece of advice. It may be correct for doing it directly in the shell, but in PHP you need the leading 0 to force the numbers to octal: 0755 is exactly the same as 00755 and 000755 (etc.), but different from plain 755. > > Right: > chmod 0755 file.php > chmod 1777 file.php > chmod('file.php',0755); > chmod('file.php',1777); That last statement is the same as: chmod('file.php', 03361) which I don't think will have the desired effect!! > Will almost always work, but isn't entirely correct: Not even nearly correct: > chmod 755 file.php > chmod 644 file.php > chmod('file.php',755); ... same as: chmod('file.php', 01363); > chmod('file.php',644); ... same as: chmod('file.php', 01204); > Will never (or at least, SHOULD never) work: On the contrary, the PHP versions of these are entirely correct -- you *need* the leading zeros to make the numeric literals be octal: > chmod 00755 file.php > chmod 01777 file.php > chmod('file.php',00755); > chmod('file.php',01777); Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, JG125, The Headingley Library, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 812 4730 Fax: +44 113 812 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php