<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >SAMConnection->peek()</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="SAMConnection->isConnected()" HREF="function.samconnection-isconnected.html"><LINK REL="NEXT" TITLE="SAMConnection->peekAll()" HREF="function.samconnection-peekall.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.samconnection-isconnected.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.samconnection-peekall.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.samconnection-peek" ></A >SAMConnection->peek()</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN200649" ></A ><P > (no version information, might be only in CVS)</P >SAMConnection->peek() -- Read a message from a queue without removing it from the queue. </DIV ><DIV CLASS="refsect1" ><A NAME="AEN200652" ></A ><H2 >说明</H2 >class <B CLASS="classname" >SAMConnection</B > { <BR ></BR >SAMMessage <B CLASS="methodname" >peek</B > ( string target [, array properties] )<BR ></BR >}</DIV ><DIV CLASS="refsect1" ><A NAME="AEN200666" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >target</CODE ></DT ><DD ><P > The identity of the queue from which to peek the message. </P ></DD ><DT ><CODE CLASS="parameter" >properties</CODE ></DT ><DD ><P > An optional associative array of properties describing other parameters to control the peek operation. <DIV CLASS="informaltable" ><P ></P ><A NAME="AEN200680" ></A ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >Property name</TH ><TH >Possible values</TH ></TR ></THEAD ><TBODY ><TR ><TD >SAM_CORRELID</TD ><TD > This is the target correlation id string of the message. This would typically have been returned by a "send" request. </TD ></TR ><TR ><TD >SAM_MESSAGEID</TD ><TD > This is the message id string of the message which is to be peeked. </TD ></TR ></TBODY ></TABLE ><P ></P ></DIV > </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN200693" ></A ><H2 >返回值</H2 ><P > This method returns a SAMMessage object or <TT CLASS="constant" ><B >FALSE</B ></TT > if an error occurs. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN200697" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN200700" ></A ><P ><B >例 1. Retrieve the next message from a queue without removing it</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$msg </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-></font><font color="#0000BB">peek</font><font color="#007700">(</font><font color="#DD0000">'queue://receive/test'</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$msg</font><font color="#007700">) {<br /> </font><font color="#FF8000">// The peek failed!<br /> </font><font color="#007700">echo </font><font color="#DD0000">"Peek failed ($conn</font><font color="#007700">-></font><font color="#DD0000">errno) $conn</font><font color="#007700">-></font><font color="#DD0000">error"</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN200704" ></A ><P ><B >例 2. Retrieve a specific message from a queue without removing it from the queue</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />$msg </font><font color="#007700">= </font><font color="#0000BB">$conn</font><font color="#007700">-></font><font color="#0000BB">peek</font><font color="#007700">(</font><font color="#DD0000">'queue://receive/test'</font><font color="#007700">, array(</font><font color="#0000BB">SAM_MESSAGEID </font><font color="#007700">=> </font><font color="#0000BB">$messageId</font><font color="#007700">));<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN200707" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.samconnection-peekall.html" >SAMConnection->peekAll()</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.samconnection-isconnected.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="function.samconnection-peekall.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >SAMConnection->isConnected()</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.sam.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >SAMConnection->peekAll()</TD ></TR ></TABLE ></DIV ></BODY ></HTML >