<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.msg-send.php',
    1 => 'msg_send',
    2 => 'Send a message to a message queue',
  ),
  'up' => 
  array (
    0 => 'ref.sem.php',
    1 => 'Semaphore 函数',
  ),
  'prev' => 
  array (
    0 => 'function.msg-remove-queue.php',
    1 => 'msg_remove_queue',
  ),
  'next' => 
  array (
    0 => 'function.msg-set-queue.php',
    1 => 'msg_set_queue',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sem/functions/msg-send.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.msg-send" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">msg_send</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">msg_send</span> &mdash; <span class="dc-title">Send a message to a message queue</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.msg-send-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>msg_send</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.sysvmessagequeue.php" class="type SysvMessageQueue">SysvMessageQueue</a></span> <code class="parameter">$queue</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$message_type</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span> <code class="parameter">$message</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$serialize</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$blocking</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter reference">&$error_code</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   <span class="function"><strong>msg_send()</strong></span> sends a <code class="parameter">message</code> of type
   <code class="parameter">message_type</code> (which MUST be greater than 0) to
   the message queue specified by <code class="parameter">queue</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.msg-send-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">queue</code></dt>
    <dd>
     <span class="simpara">
      The message queue.
     </span>
    </dd>
   
   
    <dt><code class="parameter">message_type</code></dt>
    <dd>
     <span class="simpara">
      The type of the message (MUST be greater than 0)
     </span>
    </dd>
   
   
    <dt><code class="parameter">message</code></dt>
    <dd>
     <span class="simpara">
      The body of the message.
     </span>
     <blockquote class="note"><p><strong class="note">注意</strong>: 
      <span class="simpara">
       If <code class="parameter">serialize</code> set to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> is supplied,
       MUST be of type: <span class="type"><a href="language.types.string.php" class="type string">string</a></span>, <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>, <span class="type"><a href="language.types.float.php" class="type float">float</a></span>
       or <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>. In other case a warning will be issued.
      </span>
     </p></blockquote>
    </dd>
   
   
    <dt><code class="parameter">serialize</code></dt>
    <dd>
     <span class="simpara">
      The optional <code class="parameter">serialize</code> controls how the
      <code class="parameter">message</code> is sent.  <code class="parameter">serialize</code>
      defaults to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> which means that the <code class="parameter">message</code> is
      serialized using the same mechanism as the session module before being
      sent to the queue.  This allows complex arrays and objects to be sent to
      other PHP scripts, or if you are using the WDDX serializer, to any WDDX
      compatible client.
     </span>
    </dd>
   
   
    <dt><code class="parameter">blocking</code></dt>
    <dd>
     <span class="simpara">
      If the message is too large to fit in the queue, your script will wait
      until another process reads messages from the queue and frees enough
      space for your message to be sent.
      This is called blocking; you can prevent blocking by setting the
      optional <code class="parameter">blocking</code> parameter to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, in which
      case <span class="function"><strong>msg_send()</strong></span> will immediately return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the
      message is too big for the queue, and set the optional
      <code class="parameter">error_code</code> to <strong><code><a href="sem.constants.php#constant.msg-eagain">MSG_EAGAIN</a></code></strong>,
      indicating that you should try to send your message again a little
      later on.
     </span>
    </dd>
   
   
    <dt><code class="parameter">error_code</code></dt>
    <dd>
     <span class="simpara">
      If the function fails, the optional errorcode will be set to the value of the system errno variable.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.msg-send-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>， 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
  <p class="simpara">
   Upon successful completion the message queue data structure is updated as
   follows: <code class="parameter">msg_lspid</code> is set to the process-ID of the
   calling process, <code class="parameter">msg_qnum</code> is incremented by 1 and
   <code class="parameter">msg_stime</code> is set to the current time.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.msg-send-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">queue</code> expects a <span class="classname"><a href="class.sysvmessagequeue.php" class="classname">SysvMessageQueue</a></span>
       instance now; previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was expected.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.msg-send-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.msg-remove-queue.php" class="function" rel="rdfs-seeAlso">msg_remove_queue()</a> - Destroy a message queue</span></li>
   <li><span class="function"><a href="function.msg-receive.php" class="function" rel="rdfs-seeAlso">msg_receive()</a> - Receive a message from a message queue</span></li>
   <li><span class="function"><a href="function.msg-stat-queue.php" class="function" rel="rdfs-seeAlso">msg_stat_queue()</a> - Returns information from the message queue data structure</span></li>
   <li><span class="function"><a href="function.msg-set-queue.php" class="function" rel="rdfs-seeAlso">msg_set_queue()</a> - Set information in the message queue data structure</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>