如果您因某些原因需要 euid 而不依賴 php-posix 的可用性,請嘗試
<?php
函式 geteuid_without_posix_dependency(): int
{
試著 {
// 如果可用,這個方法更快
返回 \posix_geteuid();
} 捕捉 (\Throwable $ex) {
// php-posix 不可用.. 退回到 hack
$t = tmpfile();
$ret = fstat($t)["uid"];
fclose($t);
返回 $ret;
}
}