https://segmentfault.com/q/1010000004223227?_ea=534609
Find an answer here but don't understand why it's unpack instead of pack
Reply content:
https://segmentfault.com/q/1010000004223227?_ea=534609
Find an answer here but don't understand why it's unpack instead of pack
Take a good look at it, this should be very understood.
A string in PHP
is implemented by a byte array plus an integer indicating the length of the buffer. There is no information on how to convert bytes into characters, as determined by the programmer. There is no limit to what values a string consists of, and, in particular, its value is
0 ("NUL bytes") bytes can be anywhere in the string (although there are several functions that are referred to in this manual as non-"binary security", it may be NUL
The data after the byte is ignored).
This attribute of the string type explains why there is no separate "byte" type in PHP-it has been replaced with a string. Functions that return non-literal values-
For example, any data read from a network socket-the string will still be returned.
Above excerpt from manual http://php.net/manual/zh/language.types.string.php
PHP inside a string is a byte array, do not convert, the general transmission of the number type only need pack.
The array subscript generated by unpack is starting from 1, not starting from 0, which is a little odd.