不灭的焱

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2013-04-09 00:48:14  修改时间:2024-04-18 17:39:28  分类:PHP基础  编辑

定义和用法

realpath() 函数返回绝对路径。

该函数删除所有符号连接(比如 '/./', '/../' 以及多余的 '/'),返回绝对路径名。

若失败,则返回 false。比如说文件不存在的话。

例如:

<?php
    echo realpath("test.txt");
?>

输出:

C:\Inetpub\testweb\test.txt

又如:

<?php
$str = "d:\My Documents\1\";
echo realpath($str);
?>

输出:

D:\My Documents\1
 也就是说,物理路径后面是不带 “” 或 “/” 的!