PHP implements binary data processing. php processes 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.