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

From: Date: Tue, 14 Jun 2016 13:59:48 +0000
Subject: Doc #55566 [Opn->Ver]: Example 2 for fileperms is wrong
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13511@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: Open +Status: Verified Type: Documentation Problem Package: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#13511) next »