<?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.realpath.php',
    1 => 'realpath',
    2 => '正規化された絶対パス名を返す',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'ファイルシステム 関数',
  ),
  'prev' => 
  array (
    0 => 'function.readlink.php',
    1 => 'readlink',
  ),
  'next' => 
  array (
    0 => 'function.realpath-cache-get.php',
    1 => 'realpath_cache_get',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/filesystem/functions/realpath.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.realpath" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">realpath</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">realpath</span> &mdash; <span class="dc-title">正規化された絶対パス名を返す</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.realpath-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>realpath</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code></span>): <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.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>realpath()</strong></span> は、
   入力 <code class="parameter">path</code> のシンボリックリンクをすべて展開し、
   <code class="literal">/./</code>、<code class="literal">/../</code> および <code class="literal">/</code>
   などの参照をすべて解決することにより、正規化された絶対パスを返します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.realpath-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">path</code></dt>
     <dd>
      <p class="para">
       調べたいパス。
      </p>
       <blockquote class="note"><p><strong class="note">注意</strong>: 
        <p class="para">
         path の指定は必須ですが、空の文字列を指定することもできます。
         その場合はカレントディレクトリを指定したものとみなします。
        </p>
       </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.realpath-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   成功した場合は、正規化された絶対パス名を返します。
   返されるパスはシンボリックリンク、<code class="literal">/./</code> および <code class="literal">/../</code>
   要素を含みません。
   パスの末尾の区切り文字 (<code class="literal">\</code> や <code class="literal">/</code> など) は削除されます。
  </p>
  <p class="para">
   <span class="function"><strong>realpath()</strong></span> は、
   たとえばファイルが存在しないなどの失敗時に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    指定した階層にあるすべてのディレクトリに対して、
    実行中のスクリプトからの実行権限が必要です。もし権限がなければ
    <span class="function"><strong>realpath()</strong></span> は <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    大文字小文字を区別しないファイルシステムの場合は、<span class="function"><strong>realpath()</strong></span>
    が大文字小文字をどちらかにそろえるかもしれないし、そろえないかもしれません。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
	<span class="function"><strong>realpath()</strong></span> 関数は、Phar の内部にあるファイルに対しては機能しません。
	そのようなパスは、実際のパスではなく仮想パスになるからです。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    Windows では、ディレクトリへのシンボリックリンクとジャンクションは、ひとつ分しか展開されません。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">
    PHP の数値型は符号付整数であり、
    多くのプラットフォームでは 32 ビットの整数を取るため、
    ファイルシステム関数の中には
    2GB より大きなファイルについては期待とは違う値を返すものがあります。
   </span></p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-function.realpath-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>realpath()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />chdir</span><span style="color: #007700">(</span><span style="color: #DD0000">'/var/www/'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'./../../etc/passwd'</span><span style="color: #007700">) . </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'/tmp/'</span><span style="color: #007700">) . </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<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">/etc/passwd
/tmp</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>例2 Windows 上での <span class="function"><strong>realpath()</strong></span></strong></p>
    <div class="example-contents"><p>
     Windows 上で <span class="function"><strong>realpath()</strong></span>
     を実行すると、Unix 形式のパスを Windows 形式に変更します。
    </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: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'/windows/system32'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'C:\Program Files\\'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<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">C:\WINDOWS\System32
C:\Program Files</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.realpath-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.basename.php" class="function" rel="rdfs-seeAlso">basename()</a> - パスの最後にある名前の部分を返す</span></li>
    <li><span class="function"><a href="function.dirname.php" class="function" rel="rdfs-seeAlso">dirname()</a> - 親ディレクトリのパスを返す</span></li>
    <li><span class="function"><a href="function.pathinfo.php" class="function" rel="rdfs-seeAlso">pathinfo()</a> - ファイルパスに関する情報を返す</span></li>
   </ul>
  </p>
 </div>


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