PHP basename() 함수
❮ PHP 파일 시스템 참조예시
지정된 경로에서 파일 이름 반환:
<?php
$path = "/testweb/home.php";
//Show filename
echo basename($path) ."<br/>";
//Show filename, but cut off file extension for ".php" files
echo basename($path,".php");
?>
위 코드의 출력은 다음과 같습니다.
home.php
home
정의 및 사용
basename() 함수는 경로에서 파일 이름을 반환합니다.
통사론
basename(path, suffix)
매개변수 값
Parameter | Description |
---|---|
path | Required. Specifies a file path |
suffix | Optional. A file extension. If the filename has this file extension, the file extension will be cut off |
기술적 세부 사항
반환 값: | 지정된 경로의 파일 이름 |
---|---|
PHP 버전: | 4.0+ |
❮ PHP 파일 시스템 참조