Doc #55308 [Asn->Csd]: pathinfo() options parameter not as expected
| From: | mgf@php.net | Date: | Thu, 28 Jul 2011 15:14:32 +0000 |
| Subject: | Doc #55308 [Asn->Csd]: pathinfo() options parameter not as expected | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6950@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55308&edit=1
ID: 55308
Updated by: mgf@php.net
Reported by: m dot ford at leedsmet dot ac dot uk
Summary: pathinfo() options parameter not as expected
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: *Directory/Filesystem functions
PHP Version: 5.3.6
Assigned To: mgf
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-07-28 11:25:10] mgf@php.net
OK, I've already got a doc patch on the go for this - will finish and commit soon.
------------------------------------------------------------------------
[2011-07-28 11:20:36] laruence@php.net
generally speaking we mean add by "|", which is PATHINFO_FILENAME|PATHINFO_EXTENSION,
but nerver mind, it's not the problem's reason.
and I think the doc should correct the description about the second paramter: "You can specify
which elements are returned with optional parameter options. It composes from PATHINFO_DIRNAME,
PATHINFO_BASENAME, PATHINFO_EXTENSION and PATHINFO_FILENAME. It defaults to return all
elements."
obviously "which elements" should be "which element".
------------------------------------------------------------------------
[2011-07-28 10:33:35] m dot ford at leedsmet dot ac dot uk
Description:
------------
The options parameter of pathinfo() does not seem to operate according to the description in the
manual, nor as might be expected. The manual description implies that if an options value consisting
of more than one of the bitwise PATHINFO_* constants is supplied, the return value will be a string
consisting of all the parts requested; however, this is not the case -- only the part corresponding
to the lowest bit is returned.
This seems both contrary to the documentation and completely illogical.
It would be much better if pathinfo returned an array of the requested elements, *except* when a
single element is requested. If this is deemed not possible due to BC, either the behaviour or the
documentation should be fixed so that they match!
Test script:
---------------
<?php
$info = pathinfo('/path/name/file.ext', PATHINFO_FILENAME+PATHINFO_EXTENSION);
var_dump($info);
?>
Expected result:
----------------
EITHER:
array(2) {
["extension"]=>
string(3) "ext"
["filename"]=>
string(4) "file"
}
OR:
string(8) "file.ext"
Actual result:
--------------
string(3) "ext"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55308&edit=1