the values of fileperms() are 17901, 16895, etc. what do those integers mean? is there any relations between those integers and the second argument of chmod(), such as 0777?
It's not related to the numbers, but instead the letters (rwx, owner/group/world). You can use this to convert it to those numbers:
$perms = base_convert(fileperms($filename), 10, 8); $perms = substr($perms, (strlen($perms) - 3));