Implementation of PHP to process binary data; php to process binary data _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.