php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55566 Example 2 for fileperms is wrong
Submitted: 2011-09-01 15:58 UTC Modified: 2016-06-14 14:02 UTC
From: david dot gero at ec dot gc dot ca Assigned: cmb (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david dot gero at ec dot gc dot ca
New email:
PHP Version: OS:

 

 [2011-09-01 15:58 UTC] 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)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-01 16:08 UTC] david dot gero at ec dot gc dot ca
Or how about just $pinfo = substr("upcudubu-ulusuuu", (($perms >> 24) & 0xF), 1);
 [2011-09-01 16:10 UTC] david dot gero at ec dot gc dot ca
Sorry, should have been $pinfo = substr("upcudubu-ulusuuu", (($perms >> 12) & 0xF), 1);
 [2016-06-14 13:59 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-06-14 13:59 UTC] 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.
 [2016-06-14 14:02 UTC] 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 14:02 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-06-14 14:02 UTC] cmb@php.net
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.
 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=b852815d2e9d5b84b0f6eb47c1ca52983002fbc6
Log: Fix #55566: Example 2 for fileperms is wrong
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC