Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我运行 PHP 的系统上,我有一个 usernamefoo和一个 posix group bar。在我的 PHP 脚本中,如何测试用户名是否foo是 posix 组的成员bar?
foo
bar
试试下面的代码。
$user_name = 'foo'; $group_name = 'bar'; $group_info = posix_getgrnam($group_name); if (in_array($user_name, $group_info['members'])) { echo "{$user_name} is a member of {$group_name}"; }