[php-src] Issue #8095: dirname() produces invalid root path

From: Date: Mon, 14 Feb 2022 13:55:54 +0000
Subject: [php-src] Issue #8095: dirname() produces invalid root path
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239771@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8095 Author: mabar ### Description The following code: ```php <?php echo dirname('file://file.txt'); ``` Resulted in this output: ``` file: ``` But I expected this output instead: ``` file:// ``` https://3v4l.org/6FlUN While it may not be problem with real filesystem where writing to root directory is a no-go, it's quite useful in tests for writing via custom stream wrapper into a php variable which exists just for that test. Following code used to create directories hierarchy before writing into file due to the problem creates directory vfs.var: in current working directory instead of (not) creating root directory. ```php $file = 'vfs.var://file.txt'; $dir = dirname($file); if (!@mkdir($dir, $mode, true) && !is_dir($dir)) { // exception } file_put_contents($file, ''); ``` ### PHP Version All ### Operating System _No response_

« previous php.bugs (#239771) next »