📄 function.pathinfo.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns information about a file path</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pclose.html">pclose</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.pathinfo" class="refentry"> <div class="refnamediv"> <h1 class="refname">pathinfo</h1> <p class="verinfo">(PHP 4 >= 4.0.3, PHP 5)</p><p class="refpurpose"><span class="refname">pathinfo</span> — <span class="dc-title">Returns information about a file path</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>pathinfo</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$path</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$options</tt></span> ] )</div> <p class="para rdfs-comment"> <b>pathinfo()</b> returns an associative array containing information about <i><tt class="parameter">path</tt></i>. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">path</tt></i></span> <dd> <p class="para"> The path being checked. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">options</tt></i></span> <dd> <p class="para"> You can specify which elements are returned with optional parameter <i><tt class="parameter">options</tt></i>. It composes from <b><tt>PATHINFO_DIRNAME</tt></b>, <b><tt>PATHINFO_BASENAME</tt></b>, <b><tt>PATHINFO_EXTENSION</tt></b> and <b><tt>PATHINFO_FILENAME</tt></b>. It defaults to return all elements. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The following associative <a href="language.types.array.html" class="type array">array</a> elements are returned: <i>dirname</i>, <i>basename</i>, <i>extension</i> (if any), and <i>filename</i>. </p> <p class="para"> If <i><tt class="parameter">options</tt></i> is used, this function will return a <a href="language.types.string.html" class="type string">string</a> if not all elements are requested. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.2.0</td> <td colspan="1" rowspan="1" align="left"> The <b><tt>PATHINFO_FILENAME</tt></b> constant was added. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>pathinfo()</b> Example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$path_parts </span><span style="color: #007700">= </span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/www/htdocs/index.html'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'dirname'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'basename'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'extension'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'filename'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">; </span><span style="color: #FF8000">// since PHP 5.2.0<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents"><pre><div class="cdata"><pre>/www/htdocsindex.htmlhtmlindex</pre></div> </pre></div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: For information on retrieving the current path info, read the section on <a href="language.variables.predefined.html" class="link"> predefined reserved variables</a>. <br /> </p></blockquote> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.dirname.html" class="function" rel="rdfs-seeAlso">dirname()</a></li> <li class="member"><a href="function.basename.html" class="function" rel="rdfs-seeAlso">basename()</a></li> <li class="member"><a href="function.parse-url.html" class="function" rel="rdfs-seeAlso">parse_url()</a></li> <li class="member"><a href="function.realpath.html" class="function" rel="rdfs-seeAlso">realpath()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.parse-ini-file.html">parse_ini_file</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pclose.html">pclose</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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -