downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<parse_ini_filepclose>
Last updated: Thu, 26 Jun 2008

pathinfo

(PHP 4 >= 4.0.3, PHP 5)

pathinfo — Returns information about a file path

Description

mixed pathinfo ( string $path [, int $options ] )

pathinfo() returns an associative array containing information about path .

Parameters

path

The path being checked.

options

You can specify which elements are returned with optional parameter options . It composes from PATHINFO_DIRNAME, PATHINFO_BASENAME, PATHINFO_EXTENSION and PATHINFO_FILENAME. It defaults to return all elements.

Return Values

The following associative array elements are returned: dirname, basename, extension (if any), and filename.

If options is used, this function will return a string if not all elements are requested.

ChangeLog

Version Description
5.2.0 The PATHINFO_FILENAME constant was added.

Examples

Example #1 pathinfo() Example

<?php
$path_parts
= pathinfo('/www/htdocs/index.html');

echo
$path_parts['dirname'], "\n";
echo
$path_parts['basename'], "\n";
echo
$path_parts['extension'], "\n";
echo
$path_parts['filename'], "\n"; // since PHP 5.2.0
?>

The above example will output:

/www/htdocs
index.html
html
index

Notes

Note: For information on retrieving the current path info, read the section on predefined reserved variables.



add a noteadd a note User Contributed Notes
Returns information about a file path
There are no user contributed notes for this page.




<parse_ini_filepclose>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs