Skip to Content
Programming PHP
book

Programming PHP

by Rasmus Lerdorf, Kevin Tatroe
March 2002
Intermediate to advanced
528 pages
21h 29m
English
O'Reilly Media, Inc.
Content preview from Programming PHP

Name

pack

Synopsis

string pack(string format, mixed arg1[, mixed arg2[, ... mixed argN]])

Creates a binary string containing packed versions of the given arguments according to format. Each character may be followed by a number of arguments to use in that format, or an asterisk (*), which uses all arguments to the end of the input data. If no repeater argument is specified, a single argument is used for the format character. The following characters are meaningful in the format string:

a

NUL-byte-padded string

A

Space-padded string

h

Hexadecimal string, with the low nibble first

H

Hexadecimal string, with the high nibble first

c

Signed char

C

Unsigned char

s

16-bit, machine-dependent byte-ordered signed short

S

16-bit, machine-dependent byte-ordered unsigned short

n

16-bit, big-endian byte-ordered unsigned short

v

16-bit, little-endian byte-ordered unsigned short

i

Machine-dependent size and byte-ordered signed integer

I

Machine-dependent size and byte-ordered unsigned integer

l

32-bit, machine-dependent byte-ordered signed long

L

32-bit, machine-dependent byte-ordered unsigned long

N

32-bit, big-endian byte-ordered unsigned long

V

32-bit, little-endian byte-ordered unsigned long

f

Float in machine-dependent size and representation

d

Double in machine-dependent size and representation

x

NUL-byte

X

Back up one byte

@

Fill to absolute position (given by the repeater argument) with NUL-bytes

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming PHP, 3rd Edition

Programming PHP, 3rd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Programming PHP, 2nd Edition

Programming PHP, 2nd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Clean Code in PHP

Clean Code in PHP

Carsten Windler, Alexandre Daubois

Publisher Resources

ISBN: 1565926102Supplemental ContentCatalog PageErrata