路径辅助函数

路径辅助函可以让您使用服务器端的文件路径来工作。

载入辅助函数

使用如下代码来载入路径辅助函数:

  1. $this->load->helper('path');
可用函数: ## set_realpath() 检查路径是否有效。此函数会返回一个没有符号连接的服务器路径或相对目录结构,函数中的第二个参数为TRUE时,如果程序无法确定指定的路径,则会触发一个错误。
  1. $directory = '/etc/passwd';
  2. echo set_realpath($directory);
  3. // returns "/etc/passwd"
  4. $non_existent_directory = '/path/to/nowhere';
  5. echo set_realpath($non_existent_directory, TRUE);
  6. // returns an error, as the path could not be resolved
  7. echo set_realpath($non_existent_directory, FALSE);
  8. // returns "/path/to/nowhere"

翻译贡献者:Hex, shishirui