|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64995 Function basename works icorrect with spaces
Submitted: 2013-06-08 12:54 UTC Modified: 2013-10-15 11:54 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: svmk-tmsk at yandex dot ru Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.4Git-2013-06-08 (Git) OS: Linux svmk-laptop 3.8.0-23-gener
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: svmk-tmsk at yandex dot ru
New email:
PHP Version: OS:


 [2013-06-08 12:54 UTC] svmk-tmsk at yandex dot ru
PHP version - PHP 5.4.9-4ubuntu2 (cli) (built: Mar 11 2013 16:05:09) 

Function basename works incorrect with spaces in cyrillic encoding. This function separates filename by a space. For example basename("www/abc defg") = "defg". It should be "abc defg". The letters should be in Cyrillic like 'абв где'.

1. Set locale ru_RU.UTF-8
2. Run this code echo basename('абв где');
3. basename return 'где'. basename must return 'абв где'.

Test script:
echo basename('абв где');

Expected result:
baseline function should't divide string by space.

Actual result:
basename('путь до каталога/абв  где') = 'где'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-08 15:49 UTC]
-Status: Open +Status: Feedback
 [2013-06-08 15:49 UTC]
Are you sure you are using UTF-8 and not CP1251 there? You set your locale to 
UTF8, and I tested your code with the UTF8:

echo basename('абв где');

And it works just fine.


php > echo basename('путь до каталога/абв  где');
абв  где

If you are using CP1251 you can try calling:


before your basename() call. Does it change anything?
 [2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Aug 10 20:01:24 2020 UTC