<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.posix.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.posix-setgid.php',
    1 => 'posix_setgid',
    2 => 'Set the GID of the current process',
  ),
  'up' => 
  array (
    0 => 'ref.posix.php',
    1 => 'POSIX 函数',
  ),
  'prev' => 
  array (
    0 => 'function.posix-seteuid.php',
    1 => 'posix_seteuid',
  ),
  'next' => 
  array (
    0 => 'function.posix-setpgid.php',
    1 => 'posix_setpgid',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/posix/functions/posix-setgid.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.posix-setgid" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">posix_setgid</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">posix_setgid</span> &mdash; <span class="dc-title">Set the GID of the current process</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.posix-setgid-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>posix_setgid</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$group_id</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Set the real group ID of the current process. This is a
   privileged function and needs appropriate privileges (usually
   root) on the system to be able to perform this function. The
   appropriate order of function calls is
   <span class="function"><strong>posix_setgid()</strong></span> first,
   <span class="function"><a href="function.posix-setuid.php" class="function">posix_setuid()</a></span> last.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    If the caller is a super user, this will also set the effective
    group id.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.posix-setgid-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">group_id</code></dt>
     <dd>
      <p class="para">
       The group id.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.posix-setgid-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.posix-setgid-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>posix_setgid()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     This example will print out the effective group id, once it is changed.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'My real group id is '</span><span style="color: #007700">.</span><span style="color: #0000BB">posix_getgid</span><span style="color: #007700">(); </span><span style="color: #FF8000">//20<br /></span><span style="color: #0000BB">posix_setgid</span><span style="color: #007700">(</span><span style="color: #0000BB">40</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">'My real group id is '</span><span style="color: #007700">.</span><span style="color: #0000BB">posix_getgid</span><span style="color: #007700">(); </span><span style="color: #FF8000">//40<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'My effective group id is '</span><span style="color: #007700">.</span><span style="color: #0000BB">posix_getegid</span><span style="color: #007700">(); </span><span style="color: #FF8000">//40<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.posix-setgid-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.posix-getgrgid.php" class="function" rel="rdfs-seeAlso">posix_getgrgid()</a> - Return info about a group by group id</span></li>
    <li><span class="function"><a href="function.posix-getgid.php" class="function" rel="rdfs-seeAlso">posix_getgid()</a> - Return the real group ID of the current process</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>