2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 07:05:15 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.basename">
|
2007-02-03 08:13:44 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>basename</refname>
|
2010-11-07 03:55:45 +00:00
|
|
|
<refpurpose>Returns trailing name component of path</refpurpose>
|
2007-02-03 08:13:44 +00:00
|
|
|
</refnamediv>
|
2007-07-01 21:31:16 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-02-03 08:13:44 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>basename</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>path</parameter></methodparam>
|
|
|
|
<methodparam choice="opt"><type>string</type><parameter>suffix</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
2010-11-07 03:55:45 +00:00
|
|
|
Given a string containing the path to a file or directory, this function
|
|
|
|
will return the trailing name component.
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
2007-07-01 21:31:16 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>path</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
A path.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
On Windows, both slash (<literal>/</literal>) and backslash
|
|
|
|
(<literal>\</literal>) are used as directory separator character. In
|
|
|
|
other environments, it is the forward slash (<literal>/</literal>).
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>suffix</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-11-07 03:55:45 +00:00
|
|
|
If the name component ends in <parameter>suffix</parameter> this will also
|
2007-07-01 21:31:16 +00:00
|
|
|
be cut off.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
2007-07-01 21:31:16 +00:00
|
|
|
Returns the base name of the given <parameter>path</parameter>.
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
2007-07-01 21:31:16 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>basename</function> example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-05-30 20:43:26 +00:00
|
|
|
<?php
|
2010-11-07 03:55:45 +00:00
|
|
|
echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL;
|
2015-06-09 20:58:47 +00:00
|
|
|
echo "2) ".basename("/etc/sudoers.d").PHP_EOL;
|
|
|
|
echo "3) ".basename("/etc/passwd").PHP_EOL;
|
|
|
|
echo "4) ".basename("/etc/").PHP_EOL;
|
|
|
|
echo "5) ".basename(".").PHP_EOL;
|
|
|
|
echo "6) ".basename("/");
|
2003-05-30 20:43:26 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2007-02-03 08:13:44 +00:00
|
|
|
</programlisting>
|
2010-11-07 03:55:45 +00:00
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
1) sudoers
|
2015-06-09 20:58:47 +00:00
|
|
|
2) sudoers.d
|
|
|
|
3) passwd
|
|
|
|
4) etc
|
|
|
|
5) .
|
|
|
|
6)
|
2010-11-07 03:55:45 +00:00
|
|
|
]]>
|
|
|
|
</screen>
|
2007-02-03 08:13:44 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
2007-07-01 21:31:16 +00:00
|
|
|
</refsect1>
|
2010-11-07 03:55:45 +00:00
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<function>basename</function> operates naively on the input string,
|
|
|
|
and is not aware of the actual filesystem, or path components such
|
|
|
|
as "<literal>..</literal>".
|
|
|
|
</para>
|
|
|
|
</note>
|
2010-11-17 08:47:14 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<function>basename</function> is locale aware, so for it to see the
|
|
|
|
correct basename with multibyte character paths, the matching locale must
|
|
|
|
be set using the <function>setlocale</function> function.
|
|
|
|
</para>
|
|
|
|
</note>
|
2010-11-07 03:55:45 +00:00
|
|
|
</refsect1>
|
2007-07-01 21:31:16 +00:00
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
2007-07-01 21:31:16 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>dirname</function></member>
|
2008-03-10 09:26:23 +00:00
|
|
|
<member><function>pathinfo</function></member>
|
2007-07-01 21:31:16 +00:00
|
|
|
</simplelist>
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-07-01 21:31:16 +00:00
|
|
|
|
2007-02-03 08:13:44 +00:00
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|