php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21755 dirname(), basename(), pathinfo() not working for Windows filenames
Submitted: 2003-01-19 13:33 UTC Modified: 2003-01-19 17:44 UTC
From: k.schroeder@php.net Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: k.schroeder@php.net
New email:
PHP Version: OS:

 

 [2003-01-19 13:33 UTC] k.schroeder@php.net
test script:
<?php
// windows
$path_win = 'C:\WINNT\anything.txt';
echo "\n".'dirname("'.$path_win.'"):'."\n";
var_dump(dirname($path_win));
echo "\n".'basename("'.$path_win.'"):'."\n";
var_dump(basename($path_win));
echo "\n".'pathinfo("'.$path_win.'"):'."\n";
var_dump(pathinfo($path_win));

// *nix
$path_nix = '/etc/anything.conf';
echo "\n".'dirname("'.$path_nix.'"):'."\n";
var_dump(dirname($path_nix));
echo "\n".'basename("'.$path_nix.'"):'."\n";
var_dump(basename($path_nix));
echo "\n".'pathinfo("'.$path_nix.'"):'."\n";
var_dump(pathinfo($path_nix));
?>

output:

dirname("C:\WINNT\anything.txt"):
string(1) "."

basename("C:\WINNT\anything.txt"):
string(21) "C:\WINNT\anything.txt"

pathinfo("C:\WINNT\anything.txt"):
array(3) {
  ["dirname"]=>
  string(1) "."
  ["basename"]=>
  string(21) "C:\WINNT\anything.txt"
  ["extension"]=>
  string(3) "txt"
}

dirname("/etc/anything.conf"):
string(4) "/etc"

basename("/etc/anything.conf"):
string(13) "anything.conf"

pathinfo("/etc/anything.conf"):
array(3) {
  ["dirname"]=>
  string(4) "/etc"
  ["basename"]=>
  string(13) "anything.conf"
  ["extension"]=>
  string(4) "conf"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-19 17:44 UTC] iliaa@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

On *nix \ is not a directory separator.
 [2003-01-30 15:14 UTC] evatckovacs at netscape dot net
Someone may want to correct the documentation for these functions as they CLAIM to support both \ and /.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC