Doc #55566 [Ver->Csd]: Example 2 for fileperms is wrong

From: Date: Tue, 14 Jun 2016 14:02:27 +0000
Subject: Doc #55566 [Ver->Csd]: Example 2 for fileperms is wrong
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13512@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55566&edit=1 ID: 55566 Updated by: cmb@php.net Reported by: david dot gero at ec dot gc dot ca Summary: Example 2 for fileperms is wrong -Status: Verified +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2016-06-14 14:02:04] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=339346 Log: Fix #55566: Example 2 for fileperms is wrong ------------------------------------------------------------------------ [2016-06-14 13:59:46] cmb@php.net I don't think that the example is wrong, as the order of the checks appear to be correct. I agree, however, that the example is hard to read and fragile. A switch is most certainly a reasonable improvement. ------------------------------------------------------------------------ [2011-09-01 16:10:21] david dot gero at ec dot gc dot ca Sorry, should have been $pinfo = substr("upcudubu-ulusuuu", (($perms >> 12) & 0xF), 1); ------------------------------------------------------------------------ [2011-09-01 16:08:00] david dot gero at ec dot gc dot ca Or how about just $pinfo = substr("upcudubu-ulusuuu", (($perms >> 24) & 0xF), 1); ------------------------------------------------------------------------ [2011-09-01 15:58:20] david dot gero at ec dot gc dot ca Description: ------------ --- From manual page: http://www.php.net/function.fileperms --- The first section of example 2, where it is checking for file type, is wrong. It should be using (($perms & 0xF000) == 0xC000), (($perms & 0xF000) == 0xA000), (($perms & 0xF000) == 0x8000), etc. Even better, why not make it a switch on ($perms & 0xF000) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55566&edit=1

« previous php.doc.bugs (#13512) next »