Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > dd8ef74e7a184506d40e4328053fb785 > files > 2541

php-manual-ro-20051028-1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>pack</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Manual PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Miscellaneous Functions"
HREF="ref.misc.html"><LINK
REL="PREVIOUS"
TITLE="ignore_user_abort"
HREF="function.ignore-user-abort.html"><LINK
REL="NEXT"
TITLE="php_check_syntax"
HREF="function.php-check-syntax.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-2"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Manual PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.ignore-user-abort.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.php-check-syntax.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.pack"
></A
>pack</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN63887"
></A
><P
>    (PHP 3, PHP 4 , PHP 5)</P
>pack&nbsp;--&nbsp;Pack data into binary string.</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN63890"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>pack</B
> ( string format [, mixed args])<BR
></BR
><P
>&#13;     Pack given arguments into binary string according to
     <VAR
CLASS="parameter"
>format</VAR
>. Returns binary string containing
     data.
    </P
><P
>&#13;     The idea to this function was taken from Perl and all formatting
     codes work the same as there, however, there are some formatting
     codes that are missing such as Perl's "u" format code. The format
     string consists of format codes followed by an optional repeater
     argument. The repeater argument can be either an integer value or
     * for repeating to the end of the input data. For a, A, h, H the
     repeat count specifies how many characters of one data argument
     are taken, for @ it is the absolute position where to put the
     next data, for everything else the repeat count specifies how
     many data arguments are consumed and packed into the resulting
     binary string. Currently implemented are
    </P
><P
>&#13;     <DIV
CLASS="table"
><A
NAME="AEN63905"
></A
><P
><B
>Tabel 1. <B
CLASS="function"
>pack()</B
> format characters</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Code</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>a</TD
><TD
>NUL-padded string</TD
></TR
><TR
><TD
>A</TD
><TD
>SPACE-padded string</TD
></TR
><TR
><TD
>h</TD
><TD
>Hex string, low nibble first</TD
></TR
><TR
><TD
>H</TD
><TD
>Hex string, high nibble first</TD
></TR
><TR
><TD
>c</TD
><TD
>signed char</TD
></TR
><TR
><TD
>C</TD
><TD
>unsigned char</TD
></TR
><TR
><TD
>s</TD
><TD
>signed short (always 16 bit, machine byte order)</TD
></TR
><TR
><TD
>S</TD
><TD
>unsigned short (always 16 bit, machine byte order)</TD
></TR
><TR
><TD
>n</TD
><TD
>unsigned short (always 16 bit, big endian byte order)</TD
></TR
><TR
><TD
>v</TD
><TD
>unsigned short (always 16 bit, little endian byte order)</TD
></TR
><TR
><TD
>i</TD
><TD
>signed integer (machine dependent size and byte order)</TD
></TR
><TR
><TD
>I</TD
><TD
>unsigned integer (machine dependent size and byte order)</TD
></TR
><TR
><TD
>l</TD
><TD
>signed long (always 32 bit, machine byte order)</TD
></TR
><TR
><TD
>L</TD
><TD
>unsigned long (always 32 bit, machine byte order)</TD
></TR
><TR
><TD
>N</TD
><TD
>unsigned long (always 32 bit, big endian byte order)</TD
></TR
><TR
><TD
>V</TD
><TD
>unsigned long (always 32 bit, little endian byte order)</TD
></TR
><TR
><TD
>f</TD
><TD
>float (machine dependent size and representation)</TD
></TR
><TR
><TD
>d</TD
><TD
>double (machine dependent size and representation)</TD
></TR
><TR
><TD
>x</TD
><TD
>NUL byte</TD
></TR
><TR
><TD
>X</TD
><TD
>Back up one byte</TD
></TR
><TR
><TD
>@</TD
><TD
>NUL-fill to absolute position</TD
></TR
></TBODY
></TABLE
></DIV
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN63978"
></A
><P
><B
>Exemplu 1. <B
CLASS="function"
>pack()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$binarydata </font><font color="#007700">= </font><font color="#0000BB">pack</font><font color="#007700">(</font><font color="#DD0000">"nvc*"</font><font color="#007700">, </font><font color="#0000BB">0x1234</font><font color="#007700">, </font><font color="#0000BB">0x5678</font><font color="#007700">, </font><font color="#0000BB">65</font><font color="#007700">, </font><font color="#0000BB">66</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;       The resulting binary string will be 6 bytes long and contain
       the byte sequence 0x12, 0x34, 0x78, 0x56, 0x41, 0x42.
      </P
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Note that the distinction between signed and unsigned values only 
     affects the function <A
HREF="function.unpack.html"
><B
CLASS="function"
>unpack()</B
></A
>, where as
     function <B
CLASS="function"
>pack()</B
> gives the same result for
     signed and unsigned format codes.
    </P
><P
>&#13;     Also note that PHP internally stores <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
> values as
     signed values of a machine dependent size. If you give it an unsigned
     integer value too large to be stored that way it is converted to a
     <A
HREF="language.types.float.html"
><B
CLASS="type"
>float</B
></A
> which often yields an undesired result.
    </P
><P
>&#13;     See also
     <A
HREF="function.unpack.html"
><B
CLASS="function"
>unpack()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.ignore-user-abort.html"
ACCESSKEY="P"
>Înapoi</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Acas&#227;</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.php-check-syntax.html"
ACCESSKEY="N"
>Înainte</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>ignore_user_abort</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.misc.html"
ACCESSKEY="U"
>Sus</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>php_check_syntax</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>