Req #76702 [Opn->Fbk]: pathinfo's $options should accept a bitmask value
| From: | requinix@php.net | Date: | Sat, 04 Aug 2018 07:08:40 +0000 |
| Subject: | Req #76702 [Opn->Fbk]: pathinfo's $options should accept a bitmask value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216577@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76702&edit=1
ID: 76702
Updated by: requinix@php.net
Reported by: jerry at jmweb dot net
Summary: pathinfo's $options should accept a bitmask value
-Status: Open
+Status: Feedback
Type: Feature/Change Request
Package: Filesystem function related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
So instead, how about a constant for the combined DIRNAME+FILENAME?
Previous Comments:
------------------------------------------------------------------------
[2018-08-04 06:45:37] a at b dot c dot de
How, for example, would (PATHINFO_DIRNAME | PATHINFO_EXTENSION) or (PATHINFO_BASENAME |
PATHINFO_FILENAME) be handled?
I'd be more inclined to write the test script as:
$path = '/dir/file.ext';
$newExt = '.ext2';
['dirname' => $dir, 'basename' => $file] = pathinfo($path);
$newPath = "$dir/$file$newExt";
But that may just be me.
------------------------------------------------------------------------
[2018-08-03 22:32:26] jerry at jmweb dot net
Description:
------------
Obtaining a file's path + filename is quite cumbersome using pathinfo() since the $options
argument accept one of a discrete set of values. It would be nice if we could supply a bitmask
instead.
A real-world case is caching output from .php pages. The web server routes /path/, to
/path/index.php and it saves it's own output to /path/index.html. The next request is then
served the contents of index.html directly by the web server.
I am not sure how difficult it would be to implement, but I see it useful.
Test script:
---------------
$path = '/dir/file.ext';
$newExt = '.ext2';
$newPath = pathinfo( $path, PATHINFO_DIRNAME ) . '/' . pathinfo( $path, PATHINFO_FILENAME
) . $newExt; // /dir/file.ext2
// if pathinfo could accept a bitmask
$newPathBitmask = pathinfo( $path, PATHINFO_DIRNAME | PATHINFO_FILENAME ) . $newExt; //
/dir/file.ext2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76702&edit=1