파일시스템 함수 목록
PHP Manual

pathinfo

(PHP 4 >= 4.0.3, PHP 5)

pathinfoReturns information about a file path

설명

mixed pathinfo ( string $path [, int $options= PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME ] )

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

인수

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.

반환값

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.

변경점

버전 설명
5.2.0 The PATHINFO_FILENAME constant was added.

예제

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
?>

위 예제의 출력:

/www/htdocs
index.html
html
index

주의

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

참고


파일시스템 함수 목록
PHP Manual