From php manual:
"This function does NOT convert a hexadecimal number to a binary number. This can be done using the base_convert()
function."
"Decodes a hexadecimally encoded (binary) string" and "Returns the binary representation of the given data"
(machine code ie. what's written to disk or processed by the computer hardware)
To answer your question:
Yes 'example hex data'
is a (decoded) binary representation of (the given text) data.
The hex (encoded) representation of the same data is 6578616d706c65206865782064617461
.
To display the binary (base 2) equivalent of the above hex (base 16) number, you'd base_convert()
it (to get a string of 0s & 1s; the ASCII codes/representation)
The confusion seems to arise between the results of hex2bin
and base_convert()
.
As an example:
Some data on disk can be displayed (on console) as 'A'
bin2hex
would return this (encoded) as '41' (hex representation).
base_convert()
would return this (same) data as '01000001'
hex2bin
would then decode this '41' to the machine (ASCII)
code equivalent 'A' (the binary representation, which may be written to disk as binary data)