<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.13 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.dirname"> <refnamediv> <refname>dirname</refname> <refpurpose>Returns directory name component of path</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>dirname</methodname> <methodparam><type>string</type><parameter>path</parameter></methodparam> </methodsynopsis> <para> Given a string containing a path to a file, this function will return the name of the directory. </para> </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> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns the name of the directory. If there are no slashes in <parameter>path</parameter>, a dot ('<literal>.</literal>') is returned, indicating the current directory. Otherwise, the returned string is <parameter>path</parameter> with any trailing <literal>/component</literal> removed. </para> </refsect1> <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>5.0.0</entry> <entry> <function>dirname</function> is now binary safe </entry> </row> <row> <entry>4.0.3</entry> <entry> <function>dirname</function> was fixed to be POSIX-compliant. </entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>dirname</function> example</title> <programlisting role="php"> <![CDATA[ <?php $path = "/etc/passwd"; $file = dirname($path); // $file is set to "/etc" ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="notes"> &reftitle.notes; <note> <para> Since PHP 4.3.0, you will often get a slash or a dot back from <function>dirname</function> in situations where the older functionality would have given you the empty string. </para> </note> <para> Check the following change example: <informalexample> <programlisting role="php"> <![CDATA[ <?php //before PHP 4.3.0 dirname('c:/'); // returned '.' //after PHP 4.3.0 dirname('c:/x'); // returns 'c:\' dirname('c:/Temp/x'); // returns 'c:/Temp' dirname('/x'); // returns '\' ?> ]]> </programlisting> </informalexample> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>basename</function></member> <member><function>pathinfo</function></member> <member><function>realpath</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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 sgml-default-dtd-file:"../../../../manual.ced" 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 -->