[clug] PHP fileperms()

Jamie Reid jamie at jre.id.au
Wed Jan 30 07:46:35 UTC 2019


I steered you slightly wrong there Bryan. Apologies. Time for me to leave
work I think.

It's not the lower four bits we're interested in, but rather the first four
characters returned
from the sprinf to octal.

-J

On Wed, Jan 30, 2019 at 6:43 PM Jamie Reid <jamie at jre.id.au> wrote:

> Hi Bryan,
>
> From the documentation[1]: "Returns the file's permissions as a numeric
> mode.
> Lower bits of this mode are the same as the permissions expected by
> chmod(),
> however on most platforms the return value will also include information
> on the
> type of file given as filename."
>
> It's probably going to be most useful to you to format the lower four bits
> of
> this output into an octal representation -- something that looks like 0755.
>
> An example from the documentation shows how to do this:
>
>     echo substr(sprintf('%o', fileperms('/tmp')), -4);
>
> There are likely more efficient/others ways to achieve the same lower in
> the page
> but the above seems the easiest to understand.
>
> HTH,
> Jamie
>
>
> [1]: http://php.net/manual/en/function.fileperms.php
>
> On Wed, Jan 30, 2019 at 6:21 PM Bryan Kilgallin via linux <
> linux at lists.samba.org> wrote:
>
>> I used this to check two test files: txt and php. The result in both
>> cases was "33188". What does this number mean, in terms of file
>> permissions?
>> --
>> members.iinet.net.au/~kilgallin/
>>
>> --
>> linux mailing list
>> linux at lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux
>>
>


More information about the linux mailing list