PHP

basename — Returns filename component of path
string basename ( string $path [, string $suffix ] )

Example #1 basename() example

<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);         // $file is set to "index.php"
$file = basename($path, ".php"); // $file is set to "index"
?>

  • Comment 2012-05-01 18:50
path 파일 경로명 중에서 파일명만 잘라서 반환한다. 경로 구분자는 슬래시(/) 이며, 윈도우 서버 환경에서는 역슬래쉬와 슬래쉬가 모두 경로 구분자가 된다.
suffix 인자가 지정되면 suffix도 경로 구분자가 된다.