sam.messages.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 90 行
HTML
90 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Messages</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sam.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="sam.operations.html">Messaging operations</a></div> <div class="up"><a href="sam.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="sam.messages" class="section"> <h2 class="title">Messages</h2> <p class="para"> Messages sent to and received from queues are represented by the SAMMessage object. The SAMMessage object encapsulates the body of the message (if one exists) and the header properties associated with the message. A SAMMessage object is either supplied as a parameter to a messaging operation or returned as a result. </p> <p class="para"> <div class="example"> <p><b>Example #1 Creating a message with a simple text body</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 simple text message'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> Messages may have header properties associated with them that provide control over the transport of the message or further information to the receiving application. By default message properties are delivered to the underlying messaging system as strings and in this case they may be set with the following simple syntax: </p> <p class="para"> <div class="example"> <p><b>Example #2 Setting a text format property using the default syntax</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">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myPropertyName </span><span style="color: #007700">= </span><span style="color: #DD0000">'textData'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> 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 class="para"> <div class="example"> <p><b>Example #3 Setting a property using a type hint</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">-></span><span style="color: #0000BB">header</span><span style="color: #007700">-></span><span style="color: #0000BB">myPropertyName </span><span style="color: #007700">= array(</span><span style="color: #0000BB">3.14159</span><span style="color: #007700">, </span><span style="color: #0000BB">SAM_FLOAT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> Properties may also be extracted from the header of a message. </p> <p class="para"> <div class="example"> <p><b>Example #4 Retrieving a property from a message header</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$myProperty </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: #0000BB">myPropertyName</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sam.examples.html">Examples</a></div> <div class="next" style="text-align: right; float: right;"><a href="sam.operations.html">Messaging operations</a></div> <div class="up"><a href="sam.examples.html">Examples</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?