<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.chgrp.php',
    1 => 'chgrp',
    2 => '改变文件所属的组',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => '文件系统函数',
  ),
  'prev' => 
  array (
    0 => 'function.basename.php',
    1 => 'basename',
  ),
  'next' => 
  array (
    0 => 'function.chmod.php',
    1 => 'chmod',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/filesystem/functions/chgrp.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.chgrp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chgrp</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">chgrp</span> &mdash; <span class="dc-title">改变文件所属的组</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.chgrp-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chgrp</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$group</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   尝试将文件 <code class="parameter">filename</code> 所属的组改成
   <code class="parameter">group</code>（通过组名或组 ID
   指定）。
  </p>
  <p class="para">
   只有超级用户可以任意修改文件的组，其它用户可能只能将文件的组改成该用户自己所在的组。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chgrp-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       文件的路径。
      </p>
     </dd>
    
    
     <dt><code class="parameter">group</code></dt>
     <dd>
      <p class="para">
       组的名称或数字。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chgrp-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.chgrp-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 改变文件所属的组</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$filename </span><span style="color: #007700">= </span><span style="color: #DD0000">'shared_file.txt'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$format </span><span style="color: #007700">= </span><span style="color: #DD0000">"%s's Group ID @ %s: %d\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">, </span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'r'</span><span style="color: #007700">), </span><span style="color: #0000BB">filegroup</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">chgrp</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">clearstatcache</span><span style="color: #007700">(); </span><span style="color: #FF8000">// 不要缓存 filegroup() 结果<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">, </span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'r'</span><span style="color: #007700">), </span><span style="color: #0000BB">filegroup</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.chgrp-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">此函数不能作用于<a href="features.remote-files.php" class="link">远程文件</a>，被检查的文件必须是可通过服务器的文件系统访问的。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    在 Windows 上，此函数应用在常规文件时会默默失败。
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.chgrp-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.chown.php" class="function" rel="rdfs-seeAlso">chown()</a> - 改变文件的所有者</span></li>
    <li><span class="function"><a href="function.chmod.php" class="function" rel="rdfs-seeAlso">chmod()</a> - 改变文件模式</span></li>
   </ul>
  </p>
 </div>


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