
SplFileInfo::getPathname 메소드는 파일 또는 디렉토리의 절대 경로를 반환하는 PHP 메소드입니다.
SplFileInfo 클래스는 파일 또는 디렉토리의 정보를 가져올 수 있는 클래스입니다. getPathname 메소드는 해당 파일 또는 디렉토리의 절대 경로를 반환하는 메소드입니다.
getPathname 메소드는 다음과 같은 예시를 통해 사용할 수 있습니다.
#hostingforum.kr
php
$filePath = '/path/to/file.txt';
$fileInfo = new SplFileInfo($filePath);
echo $fileInfo->getPathname(); // /path/to/file.txt
또한 디렉토리의 절대 경로를 반환하는 예시도 있습니다.
#hostingforum.kr
php
$dirPath = '/path/to/dir';
$dirInfo = new SplFileInfo($dirPath);
echo $dirInfo->getPathname(); // /path/to/dir
파일 또는 디렉토리의 절대 경로를 반환하는 메소드인 getPathname 메소드는 파일의 경로, 디렉토리의 경로, 파일명, 디렉토리명과 같은 정보를 반환할 수 있습니다.
#hostingforum.kr
php
$filePath = '/path/to/file.txt';
$fileInfo = new SplFileInfo($filePath);
echo $fileInfo->getPathname() . "n"; // /path/to/file.txt
echo $fileInfo->getPath() . "n"; // /path/to
echo $fileInfo->getFilename() . "n"; // file.txt
또한 디렉토리의 절대 경로를 반환하는 예시도 있습니다.
#hostingforum.kr
php
$dirPath = '/path/to/dir';
$dirInfo = new SplFileInfo($dirPath);
echo $dirInfo->getPathname() . "n"; // /path/to/dir
echo $dirInfo->getPath() . "n"; // /path/to
echo $dirInfo->getFilename() . "n"; // dir
getPathname 메소드는 파일 또는 디렉토리의 절대 경로를 반환하는 메소드입니다. 따라서 파일 또는 디렉토리의 절대 경로를 얻을 때 사용할 수 있습니다.
2025-08-08 09:54