Doc #69263 [Com]: dirname() removes only some double-slashes
| From: | marc at gutt dot it | Date: | Wed, 01 Apr 2015 14:27:14 +0000 |
| Subject: | Doc #69263 [Com]: dirname() removes only some double-slashes | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12072@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69263&edit=1
ID: 69263
Comment by: marc at gutt dot it
Reported by: marc at gutt dot it
Summary: dirname() removes only some double-slashes
Status: Not a bug
Type: Documentation Problem
Package: Directory function related
Operating System: Debian
PHP Version: 5.4.38
Block user comment: N
Private report: N
New Comment:
Of course this is not a valid path, but sometimes this happens and the OS should ignore multiple
slashes at all.
But finally dirname() should remove them or not and not return a mix of both.
Previous Comments:
------------------------------------------------------------------------
[2015-03-19 19:37:14] cmb@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
Note, that dirname() is supposed to work on paths, and is not
necessarily suited for general URIs.
Also note, that the double slashes in your examples are actually
errors (except the double slashes after the colon following the
protocol).
------------------------------------------------------------------------
[2015-03-19 11:41:28] marc at gutt dot it
Description:
------------
---
From manual page: http://www.php.net/function.dirname
---
dirname() removes ending double slash, but does not replace double-slash generally. It think the
ending "//" should become "/" as this is the parent.
Test script:
---------------
<?php
echo dirname('http://example.com/foo/bar//index.php')
. PHP_EOL;
//returns: http://example.com/foo/bar
echo dirname('http://example.com//foo//bar//index.php')
. PHP_EOL;
//returns: http://example.com//foo//bar
?>
Expected result:
----------------
I would expect in both cases one ending slash:
<?php
echo dirname('http://example.com/foo/bar//index.php')
. PHP_EOL;
//returns: http://example.com/foo/bar/
echo dirname('http://example.com//foo//bar//index.php')
. PHP_EOL;
//returns: http://example.com//foo//bar/
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69263&edit=1