當前位置:才華齋>設計>網頁設計>

php pack與unpack 摸板字元字元含義簡介

網頁設計 閱讀(3.25W)

format 引數的可能值:

php pack與unpack 摸板字元字元含義簡介

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 (always 16 bit, machine byte order)

S - unsigned short (always 16 bit, machine byte order)

n - unsigned short (always 16 bit, big endian byte order)

v - unsigned short (always 16 bit, 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

a一個填充空的位元組串

A一個填充空格的位元組串

b一個位串,在每個位元組裡位的順序都是升序

B一個位串,在每個位元組裡位的順序都是降序

c一個有符號char(8位整數)值

C一個無符號char(8位整數)值;關於Unicode參閱U

d本機格式的雙精度浮點數

f本機格式的單精度浮點數

h一個十六進位制串,低四位在前

H一個十六進位制串,高四位在前

i一個有符號整數值,本機格式

I一個無符號整數值,本機格式

l一個有符號長整形,總是32位

L一個無符號長整形,總是32位

n一個16位短整形,“網路”位元組序(大頭在前)

N一個32位短整形,“網路”位元組序(大頭在前)

p一個指向空結尾的字串的指標

P一個指向定長字串的指標

q一個有符號四倍(64位整數)值

Q一個無符號四倍(64位整數)值

s一個有符號短整數值,總是16位

S一個無符號短整數值,總是16位,位元組序跟機器晶片有關

u一個無編碼的字串

U一個Unicode字元數字

v一個“VAX”位元組序(小頭在前)的`16位短整數

V一個“VAX”位元組序(小頭在前)的32位短整數

w一個BER壓縮的整數

x一個空位元組(向前忽略一個位元組)

X備份一個位元組

Z一個空結束的(和空填充的)位元組串

規則

1.每個字母后面都可以跟著一個數字,表示count(計數),如果count是一個*表示剩下的所有東西。

2.如果你提供的引數比$format要求的少,pack假設缺的都是空值。如果你提供的引數比$format要求的多,那麼多餘的引數被忽略。