I guess in 4. PHP is returning the value of DIRECTORY_SEPARATOR (since dirname() would ordinarily return an empty string in this instance? I'm guessing). But why doesn't it return a forward slash as per the path being examined?!
Msg#: 3752500 posted 3:45 am on Sep 29, 2008 (gmt 0)
Open up your 'My Computer', Double click on your C: drive, browse to any random folder, say 'Program Files', now look at the address bar in the window ... Windows just prefers to use backslashes instead when most other OSes, if not all other operating systems use a forward slash. Same difference.
Msg#: 3752500 posted 9:30 am on Oct 16, 2008 (gmt 0)
Yes I realise Windows uses the backslash as the directory separator, but my point is that Apache (running on Windows) is returning the forward slash in all paths ($_SERVER["SCRIPT_NAME"] etc.) and dirname() (which merely manipulates the path string - it does not check for valid paths etc.) is returning the expected forward-slashed 'string' in all cases, except when the path consists of just the root directory when the forward slash is changed to a backslash (the value of DIRECTORY_SEPARATOR).
To put it another way... if dirname() changes the forward slash to a backslash when the path consists of just the root (on Windows), why does it not do this for other paths?
Msg#: 3752500 posted 9:01 pm on Oct 20, 2008 (gmt 0)
I've never pulled the source code to check it out, but I realized this same fact long ago myself. I was using dirname to trim and get the directory structure for manipulation/redirection and ended up with unexpected results when the path handed to the function was in the root. I found myself using rtrim() to touch things up ...