📄 function.sammessage-header.html
字号:
<thead valign="middle"> <tr valign="middle"> <th colspan="1">Constant</th> <th colspan="1">Type description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_BOOLEAN</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_BYTE</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_DOUBLE</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_FLOAT</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_INT</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_LONG</td> <td colspan="1" rowspan="1" align="left"> 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 valign="middle"> <td colspan="1" rowspan="1" align="left">SAM_STRING</td> <td colspan="1" rowspan="1" align="left"> SAM will interpret the property value specified as a string and pass it to the messaging system accordingly. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #3 Setting properties as the sender of a message</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$msg </span><span style="color: #007700">= new </span><span style="color: #0000BB">SAMMessage</span><span style="color: #007700">(</span><span style="color: #DD0000">'This is a test message'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// defining SAM specific properties...<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">SAM_REPLY_TO </span><span style="color: #007700">= </span><span style="color: #DD0000">'queue://test/replyQueue'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// defining arbitrary properties...<br />//<br />// a default string property<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myStringProp1 </span><span style="color: #007700">= </span><span style="color: #DD0000">'a string property'</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">// a string property with a type hint<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myStringProp2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'another string property'</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_STRING</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// a boolean property<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myBoolProp </span><span style="color: #007700">= array(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_BOOL</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// numeric format properties<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myIntProp </span><span style="color: #007700">= array(</span><span style="color: #0000BB">32768</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_INT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myLongProp </span><span style="color: #007700">= array(</span><span style="color: #0000BB">9876543</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_LONG</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myByteProp1 </span><span style="color: #007700">= array(</span><span style="color: #0000BB">123</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_BYTE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myByteProp2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'12'</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_BYTE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myFloatProp </span><span style="color: #007700">= array(</span><span style="color: #0000BB">3.141592</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_FLOAT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myDoubleProp </span><span style="color: #007700">= array(</span><span style="color: #0000BB">3.14159265358979</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_DOUBLE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> <div class="example"> <p><b>Example #4 Retreiving property values from a message</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// accessing an application specific property<br /></span><span style="color: #0000BB">$intProp </span><span style="color: #007700">= </span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #DD0000">'MyIntProp'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// accessing a messaging system specific property<br /></span><span style="color: #0000BB">$encoding </span><span style="color: #007700">= </span><span style="color: #0000BB">$msg</span><span style="color: #007700">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #DD0000">'JMS_IBM_Msgtype'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.sammessage-body.html" class="xref">SAMMessage->body</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sam.html">SAM Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.snmp.html">SNMP</a></div> <div class="up"><a href="ref.sam.html">SAM Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -