경로 헬퍼¶
경로 헬퍼 파일에는 서버의 파일 경로 작업을 도와주는 함수가 포함되어 있습니다.
헬퍼 로드¶
이 헬퍼는 다음 코드를 사용하여 로드합니다:
$this->load->helper('path');
사용 가능한 함수¶
사용 가능한 함수는 다음과 같습니다:
- set_realpath($path[, $check_existance = FALSE])¶
- 매개변수:
$path (
string) – 경로$check_existance (
bool) – 경로가 실제로 존재하는지 확인할지 여부
- 반환:
절대 경로
- 반환 형식:
string
심볼릭 링크나 상대 디렉터리 구조 없이 서버 경로를 반환합니다. 선택적인 두 번째 인수는 경로를 확인할 수 없는 경우 오류를 발생시킵니다.
예시:
$file = '/etc/php5/apache2/php.ini'; echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini' $non_existent_file = '/path/to/non-exist-file.txt'; echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt' $directory = '/etc/php5'; echo set_realpath($directory); // Prints '/etc/php5/' $non_existent_directory = '/path/to/nowhere'; echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere'