启动php7绝对路径命令,返回规范化的绝对路径名 - PHP 7 中文文档

(PHP 4, PHP 5, PHP 7)

realpath – 返回规范化的绝对路径名

说明

realpath

( string $path

) : string

realpath() 扩展所有的符号连接并且处理输入的

path 中的 '/./', '/../' 以及多余的 '/'

并返回规范化后的绝对路径名。返回的路径中没有符号连接,'/./'

或 '/../' 成分。

参数

path

要检查的路径。

Note:

Whilst a path must be supplied, the value can be blank or NULL

In these cases, the value is interpreted as the current directory.

返回值

Returns the canonicalized absolute pathname on success. The resulting path

will have no symbolic link, '/./' or '/../' components.

realpath() 失败时返回 FALSE,比如说文件不存在的话。

Note:

The running script must have executable permissions on all directories in

the hierarchy, otherwise realpath() will return

FALSE.

Note:

因为 PHP 的整数类型是有符号整型而且很多平台使用 32 位整型,对 2GB

以上的文件,一些文件系统函数可能返回无法预期的结果 。

更新日志

版本

说明

5.3.0

在之前的版本中,在 *BSD

系统上,如果仅仅是 path 不存在的话,realpath()

并不会像其它系统那样返回 FALSE。

5.0.0

在此之前的版本中,如果 path 传入了空或者

NULL,将导致 realpath() 返回脚本当前的目录。

范例

Example #1 realpath() 例子

chdir('/var/www/');

echo realpath('./../../etc/passwd');

?>

以上例程会输出:

/etc/passwd

Example #2 Windows 上的 realpath()

在 Windows 上,realpath() 会将 unix 风格的路径改成 Windows 风格的。

echo realpath('/windows/system32');

?>

以上例程会输出:

C:WINDOWSSystem32

参见

[basename()](php7/function.basename) – 返回路径中的文件名部分

[dirname()](php7/function.dirname) – 返回路径中的目录部分

[pathinfo()](php7/function.pathinfo) – 返回文件路径的信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值