Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5643

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns canonicalized absolute pathname</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.realpath-cache-size.html">realpath_cache_size</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.rename.html">rename</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.realpath" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">realpath</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">realpath</span> &mdash; <span class="dc-title">Returns canonicalized absolute pathname</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.realpath-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>realpath</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
   )</div>

  <p class="para rdfs-comment">
    <span class="function"><strong>realpath()</strong></span> expands all symbolic links and
   resolves references to &#039;/./&#039;, &#039;/../&#039; and extra &#039;/&#039; characters in
   the input <em><code class="parameter">path</code></em> and returns the canonicalized
   absolute pathname.  
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.realpath-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">path</code></em></span>
     <dd>

      <p class="para">
       The path being checked.
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
         Whilst a path must be supplied, the value can be blank or <strong><code>NULL</code></strong>
         In these cases, the value is interpreted as the current directory.
        </p>
       </p></blockquote>
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.realpath-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the canonicalized absolute pathname on success. The resulting path 
   will have no symbolic link, &#039;/./&#039; or &#039;/../&#039; components.
  </p>
  <p class="para">
    <span class="function"><strong>realpath()</strong></span> returns <strong><code>FALSE</code></strong> on failure, e.g. if
   the file does not exist.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The running script must have executable permissions on all directories in
    the hierarchy, otherwise  <span class="function"><strong>realpath()</strong></span> will return
    <strong><code>FALSE</code></strong>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">
    Because PHP&#039;s integer type is signed and many platforms use 32bit integers,
    some filesystem functions may return unexpected results for files which
    are larger than 2GB.
   </span></p></blockquote>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.realpath-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        Prior to this release, if only the last <em><code class="parameter">path</code></em>
        component did not exist,  <span class="function"><strong>realpath()</strong></span> would not fail on
        *BSD systems.  <span class="function"><strong>realpath()</strong></span> now fails in this case.
       </td>
      </tr>

      <tr>
       <td>5.0.0</td>
       <td>
        Prior to this release, a blank or <strong><code>NULL</code></strong> <em><code class="parameter">path</code></em> would
        cause  <span class="function"><strong>realpath()</strong></span> to return the directory name of the script.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-function.realpath-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2426">
    <p><strong>Example #1  <span class="function"><strong>realpath()</strong></span> example</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&nbsp;</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'./../../etc/passwd'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
/etc/passwd
</pre></div>
    </div>
   </div>
   <div class="example" id="example-2427">
    <p><strong>Example #2  <span class="function"><strong>realpath()</strong></span> on Windows</strong></p>
    <div class="example-contents"><p>
     On windows  <span class="function"><strong>realpath()</strong></span> will change unix style paths to
     windows style.
    </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&nbsp;</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">'/windows/system32'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
C:\WINDOWS\System32
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.realpath-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.basename.html" class="function" rel="rdfs-seeAlso">basename()</a> - Returns trailing name component of path</span></li>
    <li class="member"> <span class="function"><a href="function.dirname.html" class="function" rel="rdfs-seeAlso">dirname()</a> - Returns parent directory's path</span></li>
    <li class="member"> <span class="function"><a href="function.pathinfo.html" class="function" rel="rdfs-seeAlso">pathinfo()</a> - Returns information about a file path</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.realpath-cache-size.html">realpath_cache_size</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.rename.html">rename</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>