Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 4143

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>SAMMessage-&#62;header</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="SAM - Simple Asynchronous Messaging"
HREF="ref.sam.html"><LINK
REL="PREVIOUS"
TITLE="SAMMessage->__construct()"
HREF="function.sammessage-constructor.html"><LINK
REL="NEXT"
TITLE="Satellite CORBA client extension [deprecated]"
HREF="ref.satellite.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.sammessage-constructor.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.satellite.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.sammessage-header"
></A
>SAMMessage-&#62;header</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN201214"
></A
><P
>    (no version information, might be only in CVS)</P
>SAMMessage-&#62;header&nbsp;--&nbsp;
   The header properties of the message.
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201217"
></A
><H2
>说明</H2
>class <B
CLASS="classname"
>SAMMessage</B
> { <BR
></BR
>object header<BR
></BR
>}<P
>&#13;   The <TT
CLASS="literal"
>header</TT
> property is a container for any system or
   user properties that area associated with the message.
  </P
><P
>&#13;   Properties may be assigned by the sender of a message to control the way
   the messaging systems handles it or may be assigned by the messaging
   system itself to tell the recipient extra information about the message or
   the way in which it has been handled.
  </P
><P
>&#13;   Some properties are understood by SAM in which case constants have been
   defined for them. The majority of properties however are ignored by the
   SAM implementation and simply passed through to the underlying messaging
   systems allowing the application to use messaging specific property names
   or to define its own "user" properties.
  </P
><P
>&#13;   The SAM defined properties are as follows:
   <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN201230"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Property name</TH
><TH
>Possible values</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SAM_MESSAGEID</TD
><TD
>&#13;        When a message is received this field contains the unique
        identifier of the message as allocated by the underlying
        messaging system. When sending a message this field is ignored.
       </TD
></TR
><TR
><TD
>SAM_REPLY_TO</TD
><TD
>&#13;        A string providing the identity of the queue on to which
        responses to this message should be posted.
       </TD
></TR
><TR
><TD
>SAM_TYPE</TD
><TD
>&#13;        <P
>&#13;         An indication of the type of message to be sent. The value may be
         <TT
CLASS="constant"
><B
>SAM_TEXT</B
></TT
> indicating the contents of the
         message body is a text string, or <TT
CLASS="constant"
><B
>SAM_BYTES</B
></TT
>
         indicating the contents of the message body are some application
         defined format.
        </P
>
        <P
>&#13;         The way in which this property is used may depend on the underlying
         messaging server. For instance a messaging server that supports the
         JMS (Java Message Service) specification may interpret this value and
         send messages of type "jms_text" and "jms_bytes". In addition, if 
         the SAM_TYPE property is set to <TT
CLASS="constant"
><B
>SAM_TEXT</B
></TT
> the
         data provided for the message body is expected to be a UTF8 encoded
         string.
        </P
>
       </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
  </P
><P
>&#13;   When setting the values of properties it is often useful to give a hint as
   to the format in which the property should be delivered to the messaging
   system.  By default property values are delivered as text and the
   following simple syntax may be used to set a value:
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201253"
></A
><P
><B
>例 1. Setting a text format property using the default syntax</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$msg </font><font color="#007700">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">();<br /><br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myPropertyName </font><font color="#007700">= </font><font color="#DD0000">'textData'</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   If it is desired to pass type information an alternative syntax may be
   used where the value and the type hint are passed in an associative
   array:
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201258"
></A
><P
><B
>例 2. Setting a text format property using a type hint</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$msg </font><font color="#007700">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">();<br /><br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myPropertyName </font><font color="#007700">= array(</font><font color="#DD0000">'textData'</font><font color="#007700">, </font><font color="#0000BB">SAM_STRING</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   When passing a type hint the type entry should be one of the SAM defined
   constant values as defined by the following table:
   <DIV
CLASS="informaltable"
><P
></P
><A
NAME="AEN201262"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Constant</TH
><TH
>Type description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>SAM_BOOLEAN</TD
><TD
>&#13;        Any value passed will be interpreted as logical true or false. 
        If the value cannot be interpreted as a PHP boolean value the value
        passed to the messaging system is undefined.
       </TD
></TR
><TR
><TD
>SAM_BYTE</TD
><TD
>&#13;        An 8-bit signed integer value. SAM will attempt to convert the
        property value specified into a single byte value to pass to the
        messaging system. If a string value is passed an attempt will be
        made to interpret the string as a numeric value. If the numeric
        value cannot be expressed as an 8-bit signed binary value data may
        be lost in the conversion.
       </TD
></TR
><TR
><TD
>SAM_DOUBLE</TD
><TD
>&#13;        A long floating point value. SAM will attempt to convert the
        property value specified into a floating point value with 15 digits
        of precision. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the passed value cannot
        be expressed as a 15 digit floating point value data may be lost in
        the conversion.
       </TD
></TR
><TR
><TD
>SAM_FLOAT</TD
><TD
>&#13;        A short floating point value. SAM will attempt to convert the
        property value specified into a floating point value with 7 digits of
        precision. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the passed value cannot
        be expressed as a 7 digit floating point value data may be lost in
        the conversion.
       </TD
></TR
><TR
><TD
>SAM_INT</TD
><TD
>&#13;        An 32-bit signed integer value. SAM will attempt to convert the
        property value specified into a 32-bit value to pass to the messaging
        system. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the numeric value cannot
        be expressed as an 32-bit signed binary value data may be lost in the
        conversion.
       </TD
></TR
><TR
><TD
>SAM_LONG</TD
><TD
>&#13;        An 64-bit signed integer value. SAM will attempt to convert the
        property value specified into a 64-bit value to pass to the messaging
        system. If a string value is passed an attempt will be made to
        interpret the string as a numeric value. If the numeric value cannot
        be expressed as an 64-bit signed binary value data may be lost in the
        conversion.
       </TD
></TR
><TR
><TD
>SAM_STRING</TD
><TD
>&#13;        SAM will interpret the property value specified as a string and pass
        it to the messaging system accordingly.
       </TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201290"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201293"
></A
><P
><B
>例 3. Setting properties as the sender of a message</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$msg </font><font color="#007700">= new </font><font color="#0000BB">SAMMessage</font><font color="#007700">(</font><font color="#DD0000">'This is a test message'</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// defining SAM specific properties...<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">SAM_REPLY_TO </font><font color="#007700">= </font><font color="#DD0000">'queue://test/replyQueue'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// defining arbitrary properties...<br />//<br />// a default string property<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myStringProp1 </font><font color="#007700">= </font><font color="#DD0000">'a string property'</font><font color="#007700">;<br /></font><font color="#FF8000">// a string property with a type hint<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myStringProp2 </font><font color="#007700">= array(</font><font color="#DD0000">'another string property'</font><font color="#007700">, </font><font color="#0000BB">SAM_STRING</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// a boolean property<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myBoolProp </font><font color="#007700">= array(</font><font color="#0000BB">FALSE</font><font color="#007700">, </font><font color="#0000BB">SAM_BOOL</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// numeric format properties<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myIntProp </font><font color="#007700">= array(</font><font color="#0000BB">32768</font><font color="#007700">, </font><font color="#0000BB">SAM_INT</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myLongProp </font><font color="#007700">= array(</font><font color="#0000BB">9876543</font><font color="#007700">, </font><font color="#0000BB">SAM_LONG</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myByteProp1 </font><font color="#007700">= array(</font><font color="#0000BB">123</font><font color="#007700">, </font><font color="#0000BB">SAM_BYTE</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myByteProp2 </font><font color="#007700">= array(</font><font color="#DD0000">'12'</font><font color="#007700">, </font><font color="#0000BB">SAM_BYTE</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myFloatProp </font><font color="#007700">= array(</font><font color="#0000BB">3.141592</font><font color="#007700">, </font><font color="#0000BB">SAM_FLOAT</font><font color="#007700">);<br /></font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#0000BB">myDoubleProp </font><font color="#007700">= array(</font><font color="#0000BB">3.14159265358979</font><font color="#007700">, </font><font color="#0000BB">SAM_DOUBLE</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN201297"
></A
><P
><B
>例 4. Retreiving property values from a message</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br /></font><font color="#FF8000">// accessing an application specific property<br /></font><font color="#0000BB">$intProp </font><font color="#007700">= </font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#DD0000">'MyIntProp'</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// accessing a messaging system specific property<br /></font><font color="#0000BB">$encoding </font><font color="#007700">= </font><font color="#0000BB">$msg</font><font color="#007700">-&gt;</font><font color="#0000BB">header</font><font color="#007700">-&gt;</font><font color="#DD0000">'JMS_IBM_Msgtype'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN201300"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.sammessage-body.html"
>SAMMessage-&#62;body</A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </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.sammessage-constructor.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="ref.satellite.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SAMMessage-&#62;__construct()</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.sam.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Satellite CORBA client extension [deprecated]</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>