php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61578 bin2hex() definition is ambiguous
Submitted: 2012-03-31 02:25 UTC Modified: 2012-04-04 09:50 UTC
Votes:2
Avg. Score:1.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: unsure at tactileint dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: unsure at tactileint dot com
New email:
PHP Version: OS:

 

 [2012-03-31 02:25 UTC] unsure at tactileint dot com
Description:
------------
---
From manual page: http://www.php.net/function.bin2hex#refsect1-function.bin2hex-description
---

"Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first. "

ambiguous.  Which you mean?

'01101000' => '68'   first nibble, 6, is higher order, 0110
or
'0110' => '30313130'  first nibble, 3, is higher order in char '0' = 30

In both cases the input string is 'binary'.  Given that '123ABC' is considered headecimal, doesn't it follow that '01101000' is binary?

Including a few unambiguous examples would solve the problem.  Like:
bin2hex('or') => '6f72'



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-02 11:41 UTC] phpmpan at mpan dot pl
I see no ambiguity in the description.

According to function description your first interpretation is wrong. It is clearly stated that `bin2hex` converts binary data, not a textual representation of a number in 2-based positional numeral system:

"bin2hex — Convert binary data into hexadecimal representation"
 [2012-04-04 09:50 UTC] bjori@php.net
-Status: Open +Status: Not a bug
 [2012-04-04 09:50 UTC] bjori@php.net
See phpmpan comment
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC