【发布时间】:2013-06-14 19:22:07
【问题描述】:
我有一个变量 $path,其中包含 Windows 网络上文件的完整路径(例如 R:\somedir\otherdir\lastdir\some.file.ext)
当我使用时:
$location = dirname($path);
这里$location只记录值.
我做错了什么?
【问题讨论】:
-
来自手册:
Since PHP 4.3.0, you will often get a slash or a dot back from dirname() in situations where the older functionality would have given you the empty string.我建议在这里阅读注释:php.net/manual/en/function.dirname.php -
感谢我已阅读此条目,$path 包含斜杠,所以我不确定发生了什么。
-
它包含反斜杠,而不是斜杠
-
好的,我已经使用以下代码解决了这个问题: $path = str_replace("\\", "/", $path); $location = 目录名($path);感谢您的帮助。
标签: php path directory dirname