|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-03-02 08:21 UTC] paul at wavebreaks dot com
Description: ------------ This is probably the same or related to http://bugs.php.net/bug.php?id=25450 and http://bugs.php.net/bug.php?id=18710 but since they are for Win 2k and/or closed, I thought the best bet was to open a new one. When a path-like-string is passed to dirname, if, and only if, the last entity (file, dir) is on the root (ie: only one / in the string) then dirname returns a backslash instead of a forward slash. There doesn't appear to be a config to tell PHP which part seperator to use, thus the dirname function is pointlessly broken unless you can guarentee it will never be given a root level entry. This, also, breaks your example in the documentation for header() for Location: header types. Reproduce code: --------------- print (dirname('/foo')."\n"); print (dirname('/foo/bar')."\n"); Expected result: ---------------- / /foo Actual result: -------------- \ /foo You might argue it's not a bug since Windows is meant to handle both types of path seperator, but a URI does not, and this is you main audience. This issue has been around for way past way too long. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
This problem still exists with version 5.2.3 (OS: Windows XP SP 2, German) like loom at nons dot de mentioned. The string dirname() return should always include the same directory separator character as the string provided. So if I use the following: print (dirname('/foo')."\n"); the function should return '/' because I used the slash as directory seperator character, too.