Path 輔助函數
路徑輔助函數檔案包含讓您使用伺服器端的檔案路徑工作的函數。
載入 輔助函數
使用下列的程式碼載入補助程式:
$this->load->helper('path');
下列為可以使用的函數:
set_realpath()
檢查路徑是否存在。此函數將傳回一個無符號連結或相對目錄結構的伺服器路徑。如果無法確定指定的路徑,則函數中的第二個參數為TRUE,會產生一個錯誤。
$directory = '/etc/passwd';
echo set_realpath($directory);
// returns "/etc/passwd"
$non_existent_directory = '/path/to/nowhere';
echo set_realpath($non_existent_directory,TRUE);
// returns an error,as the path could not be resolved
echo set_realpath($non_existent_directory,FALSE);
// returns "/path/to/nowhere"