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を実行しているシステムには、ユーザー名fooとposixグループがありbarます。fooPHPスクリプトで、ユーザー名が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}"; }