php.net |  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
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mike at mikegerwitz dot com
New email:
PHP Version: OS:

 

 [2008-11-20 19:04 UTC] mike at mikegerwitz dot com
Description:
------------
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"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-03 01:19 UTC] felipe@php.net
Nowadays unicode semantics is always enabled.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 08:01:27 2024 UTC