首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

路径助手 | Path Helper

PATH Helper文件包含允许您在服务器上使用文件路径的函数。

  • 加载此助手
  • 可用职能

加载此助手

使用以下代码加载此助手:

代码语言:javascript
复制
$this->load->helper('path');

可用职能

现有下列职能:

set_realpath($path[, $check_existance = FALSE])

参数:

$ path(string) - Path $ check_existance(bool) - 是否检查路径是否真实存在

返回:

绝对路径

返回类型:

  • $ pathstring) - 路径
  • $ check_existancebool) - 是否检查路径是否存在
代码语言:txt
复制
Returns:  An absolute path
代码语言:txt
复制
Return type:  string
代码语言:javascript
复制
该函数将返回没有符号链接或相对目录结构的服务器路径。如果路径无法解析,则可选的第二个参数将导致触发错误。

例子:

$ 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); //显示错误,因为无法解析路径echo set_realpath($ non_existent_file,FALSE); //打印'/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); //显示错误,因为无法解析路径echo set_realpath($ non_existent_directory,FALSE); //打印'/ path / to / nowhere'

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com