What is Unpack's "binary string"
I'm trying to the unpack
function. The PHP documentation says
Unpacks from a binary string into an array 开发者_StackOverflowaccording to the given format.
Does the string passed have to be a binary string? and what exactly is a binary string?
A binary string
just means data that is in it's base binary format. The data it's self is being displayed as a string to you if you where to echo it, but it would be meaningless without applying it's correct structure to it. So for example a number would not look like a number, because it's in binary. While the data is there, it has to be parsed as a number for it to be readable as a number otherwise it could look like 'abcd'.
if you read down slightly further you will see examples of what binary strings look like
$binarydata = "\x32\x42\x00\xa0";
Also the description of the method clearly says Unpacks from a binary string
, so yes it requires a binary string.
more information on binary
精彩评论