|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46634 Array key differentiates between unicode and binary strings
Submitted: 2008-11-20 19:04 UTC Modified: 2009-01-03 01:19 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mike at mikegerwitz dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 6CVS-2008-11-20 (snap) OS: GNU/Linux
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: mike at mikegerwitz dot com
New email:
PHP Version: OS:


 [2008-11-20 19:04 UTC] mike at mikegerwitz dot com
Array keys in PHP 6 differentiate between unicode and binary strings - that is, a unicode key of 'test' is entirely different than a binary key of 'test'.

Reproduce code:
$arr = array();
$arr[ (unicode)'test' ] = 'unicode';
$arr[ (binary)'test' ] = 'binary';

// If unicode semantics is enabled, this will output 'unicode'
var_dump( $arr['test'] );

// Will output 'binary'
var_dump( $arr[ b'test'] );

// Will output 'unicode'
var_dump( $arr[ (unicode)'test' ] );

Expected result:
All three lines should output 'binary'

unicode(7) "binary"
unicode(6) "binary"
unicode(7) "binary"

Actual result:
unicode(7) "unicode"
unicode(6) "binary"
unicode(7) "unicode"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-03 01:19 UTC]
Nowadays unicode semantics is always enabled.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 09:01:28 2024 UTC