🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 路径辅助函数 路径辅助函数文件包含了用于处理服务端文件路径的一些函数。 [TOC=2,3] ## [加载辅助函数](http://codeigniter.org.cn/user_guide/helpers/path_helper.html#id4) 该辅助函数通过下面的代码加载: ~~~ $this->load->helper('path'); ~~~ ## [可用函数](http://codeigniter.org.cn/user_guide/helpers/path_helper.html#id5) 该辅助函数有下列可用函数: set_realpath($path[, $check_existance = FALSE]) 参数: * **$path** (string) -- Path * **$check_existance** (bool) -- Whether to check if the path actually exists 返回: An absolute path 返回类型: string 该函数返回指定路径在服务端的绝对路径(不是符号路径或相对路径), 可选的第二个参数用于指定当文件路径不存在时是否报错。 Examples: ~~~ $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' ~~~