Bug->Doc #55308 [Opn]: pathinfo() options parameter not as expected

From: Date: Thu, 28 Jul 2011 11:20:36 +0000
Subject: Bug->Doc #55308 [Opn]: pathinfo() options parameter not as expected
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6947@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: laruence@php.net Reported by: m dot ford at leedsmet dot ac dot uk Summary: pathinfo() options parameter not as expected Status: Open -Type: Bug +Type: Documentation Problem Package: *Directory/Filesystem functions PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: 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". Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#6947) next »