PHP pack() function
definition and usage
pack() function data a binary string into.
syntax
pack(format,args+)
parameter | description |
---|---|
format | অপরিহার্য।প্যাক করার সময় ব্যবহৃত ফরম্যাটকে নির্দিষ্ট করে |
args+ | সুবিধাপূর্ণ।একটি বা একাধিক পারামিটারকে প্যাক করার জন্য নির্দিষ্ট করে |
format পারামিটারের সম্ভাব্য মানঃ
- a - NUL-padded string
- A - SPACE-padded string
- h - Hex string, low nibble first
- H - Hex string, high nibble first
- c - signed char
- C - unsigned char
- s - signed short (সবসময় 16 বিট, machine byte order)
- S - unsigned short (সবসময় 16 বিট, machine byte order)
- n - unsigned short (সবসময় 16 বিট, big endian byte order)
- v - unsigned short (সবসময় 16 বিট, little endian byte order)
- i - signed integer (machine dependent size and byte order)
- I - unsigned integer (machine dependent size and byte order)
- l - signed long (always 32 bit, machine byte order)
- L - unsigned long (always 32 bit, machine byte order)
- N - unsigned long (always 32 bit, big endian byte order)
- V - unsigned long (always 32 bit, little endian byte order)
- f - float (machine dependent size and representation)
- d - double (machine dependent size and representation)
- x - NUL byte
- X - Back up one byte
- @ - NUL-fill to absolute position
Instance
Example 1
<?php echo pack("C3",80,72,80); ?>
Output:
PHP
Example 2
<?php echo pack("C*",80,72,80); ?>
Output:
PHP