PHP implements binary data processing. php processes binary data. PHP implements binary data processing. php uses pack () and unpack () to process binary data (). Pack () is used to convert data into binary data, such as PHP to process binary data, php to process binary data
Pack () and unpack () are required for PHP to process binary data ().
Pack () is used to convert data into binary data. the usage is as follows:
Pack ("LL", 0, 1 );
Pack ("C", );
Unpack () can parse binary data into a relational array, which accepts two parameters, using the following method:
$ Arr = unpack ("Chead", $ binstream); // Read 1st bytes
$ Arr = unpack ("Chead/C3string/C4number", $ binstream); // Read 8 bytes, which can be separated by a slash
The first parameter table of the pack () and unpack () functions is as follows:
■ A: NULL-filled byte string
■ A: Space-filled byte string
■ H: hexadecimal number, four-bit lower priority
■ H: hexadecimal number, with the highest four-byte priority
■ C: signed characters
■ C: unsigned characters
■ S: Signed short integer (always 16 bits, machine byte order)
■ S: unsigned short integer (always 16 bits, machine byte order)
■ N: unsigned short integer (always 16 bits, large-tail byte order)
■ V: unsigned short integer (always 16 bits, in the smallest byte order)
■ I: signed integer (machine-related size and byte order)
■ I: unsigned integer (machine-related size and byte order)
■ L: Signed long integer (always 32-bit, machine byte order)
■ L: unsigned long integer (always 32-bit, machine byte order)
■ N: unsigned long integer (always 32-bit, large-tail byte order)
■ V: unsigned long integer (always 32-bit, in the smallest byte order)
■ F: floating point number (machine-related size and representation)
■ D: double precision (machine-related size and representation)
■ X: null bytes
■ X: regressing a byte
■ @: Fill the absolute position with NULL
The above PHP implementation method for processing binary data is all the content that I have shared with you. I hope to give you a reference, and I hope you can provide more support to the customer's house.
Pack () and unpack () are required for processing binary data in pluphp (). Pack () is used to convert data into binary data. the usage is as follows...