PHP chmod is able to set the suid/sgid bit of files, i.e. chmod('my-directory', 04775) just works fine.
However, I am unable to check if the suid/sgid bit is set with fileperms, the fourth octal digit (from the right) will always be reported as zero, i.e. fileperms('my-directory') & 07000 == 0 always holds.
The docs clearly states
The value of mode contains information read by several functions. When written in octal, starting from the right, the first three digits are returned by chmod(). The next digit is ignored by PHP. The next two digits indicate the file type: [...]
(see https://www.php.net/manual/en/function.stat.php)
Is there any option how I can check with PHP whether suid/sgid are set?
It seems a bit inconsistent that one can set the suid/sgid bit, but cannot read it.