<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.chown.php',
    1 => 'chown',
    2 => 'ファイルの所有者を変更する',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'ファイルシステム 関数',
  ),
  'prev' => 
  array (
    0 => 'function.chmod.php',
    1 => 'chmod',
  ),
  'next' => 
  array (
    0 => 'function.clearstatcache.php',
    1 => 'clearstatcache',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/filesystem/functions/chown.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.chown" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chown</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">chown</span> &mdash; <span class="dc-title">ファイルの所有者を変更する</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.chown-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chown</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">$user</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">user</code>に変更しようと試みます。
   スーパーユーザーのみがファイルの所有者を変更できます。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chown-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">user</code></dt>
     <dd>
      <p class="para">
       ユーザー名あるいはユーザー番号。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chown-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.chown-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 シンプルな <span class="function"><strong>chown()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// 使用するファイル名とユーザー名<br /></span><span style="color: #0000BB">$file_name</span><span style="color: #007700">= </span><span style="color: #DD0000">"foo.php"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$path </span><span style="color: #007700">= </span><span style="color: #DD0000">"/home/sites/php.net/public_html/sandbox/" </span><span style="color: #007700">. </span><span style="color: #0000BB">$file_name </span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$user_name </span><span style="color: #007700">= </span><span style="color: #DD0000">"root"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// ユーザーを設定します<br /></span><span style="color: #0000BB">chown</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">, </span><span style="color: #0000BB">$user_name</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// 結果を確認します<br /></span><span style="color: #0000BB">$stat </span><span style="color: #007700">= </span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #0000BB">$path</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">posix_getpwuid</span><span style="color: #007700">(</span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'uid'</span><span style="color: #007700">]));<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は、
たとえば以下のようになります。</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [name] =&gt; root
    [passwd] =&gt; x
    [uid] =&gt; 0
    [gid] =&gt; 0
    [gecos] =&gt; root
    [dir] =&gt; /root
    [shell] =&gt; /bin/bash
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.chown-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.chown-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.chmod.php" class="function" rel="rdfs-seeAlso">chmod()</a> - ファイルのモードを変更する</span></li>
    <li><span class="function"><a href="function.chgrp.php" class="function" rel="rdfs-seeAlso">chgrp()</a> - ファイルのグループを変更する</span></li>
   </ul>
  </p>
 </div>


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