php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41262 Get wrong dirname with pathinfo under Windows
Submitted: 2007-05-02 19:34 UTC Modified: 2007-05-03 06:38 UTC
From: tim at gerundt dot de Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tim at gerundt dot de
New email:
PHP Version: OS:

 

 [2007-05-02 19:34 UTC] tim at gerundt dot de
Description:
------------
If I try to get the "dirname" from the pathinfo() function under Windows with a path like "/index.php", I get "\" instead of "/" as dirname value. Under Linux I get the desired value ("/").

I tested it with PHP 5.2.1 (Apache 2.2.4, Windows XP) and PHP 4.4.6 (Apache 2.0.54, Windows 2000).

Greetings,
Tim Gerundt

Reproduce code:
---------------
<?php
  $pathinfo = pathinfo('/index.php');
  print_r($pathinfo);
?>

Expected result:
----------------
Array
(
    [dirname] => /
    [basename] => index.php
    [extension] => php
)

Actual result:
--------------
Array
(
    [dirname] => \
    [basename] => index.php
    [extension] => php
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-02 20:54 UTC] edink@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2007-05-02 22:18 UTC] tim at gerundt dot de
And why is this not a bug? The dirname from (the string) "/index.php" is "/" regardless of I call the function under Windows or Linux. If I use a path string with a sub directory (like "/test/index.php") even Windows returns the correct dirname ("/test"). The problem exist only on Windows when a (unix/web) path includes no sub directories.
 [2007-05-02 23:06 UTC] scottmac@php.net
It uses the DEFAULT_SLASH constant which on Windows is \\
 [2007-05-03 06:38 UTC] tim at gerundt dot de
> It uses the DEFAULT_SLASH constant which on Windows is \\

Thanks for the hint!

In my eyes it is still a bug, but I know now that is not a bug for you...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 05 17:01:31 2024 UTC