PHP의의 PathInfo () 함수
정의 및 사용
의 PathInfo () 함수는 파일 경로에 대한 정보의 배열을 반환합니다.
다음과 같이 배열 요소가 반환 :
- [Dirname에]
- [베이스 이름]
- [확장]
문법
pathinfo(path,options)
参数 | 描述 |
---|---|
path | 必需。规定要检查的路径。 |
options | 可选。规定要返回的数组元素。默认是 all。 可能的值:
|
팁과주의 사항
참고 : 모든 요청의 요소는의 PathInfo () 함수는 문자열을 반환합니다.
예 1
<?php
print_r(pathinfo("/testweb/test.txt"));
?>
print_r(pathinfo("/testweb/test.txt"));
?>
가 출력 위의 코드 :
Array
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
(
[dirname] => /testweb
[basename] => test.txt
[extension] => txt
)
예 2
<?php
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
print_r(pathinfo("/testweb/test.txt",PATHINFO_BASENAME));
?>
가 출력 위의 코드 :
test.txt
PHP 파일 시스템 참조 설명서를 완료