?
This document uses PHP Chinese website manual Release
PATH Helper文件包含允許您在服務(wù)器上使用文件路徑的函數(shù)。
加載此助手
可用職能
使用以下代碼加載此助手:
$this->load->helper('path');
現(xiàn)有下列職能:
set_realpath($path[, $check_existance = FALSE])
參數(shù): | $ path(string) - Path $ check_existance(bool) - 是否檢查路徑是否真實(shí)存在 |
---|---|
返回: | 絕對路徑 |
返回類型: | 串 |
$ path(string) - 路徑
$ check_existance(bool) - 是否檢查路徑是否存在
Returns: An absolute path
Return type: string
該函數(shù)將返回沒有符號鏈接或相對目錄結(jié)構(gòu)的服務(wù)器路徑。如果路徑無法解析,則可選的第二個參數(shù)將導(dǎo)致觸發(fā)錯誤。
例子:
$ file ='/etc/php5/apache2/php.ini'; echo set_realpath($ file); //打印'/etc/php5/apache2/php.ini'$ non_existent_file ='/path/to/non-exist-file.txt'; echo set_realpath($ non_existent_file,TRUE); //顯示錯誤,因?yàn)闊o法解析路徑echo set_realpath($ non_existent_file,F(xiàn)ALSE); //打印'/path/to/non-exist-file.txt'$ directory ='/ etc / php5'; echo set_realpath($ directory); //打印'/ etc / php5 /'$ non_existent_directory ='/ path / to / nowhere'; echo set_realpath($ non_existent_directory,TRUE); //顯示錯誤,因?yàn)闊o法解析路徑echo set_realpath($ non_existent_directory,F(xiàn)ALSE); //打印'/ path / to / nowhere'