Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 4052

php-manual-pt_BR-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
>readline_callback_handler_install</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="GNU Readline"
HREF="ref.readline.html"><LINK
REL="PREVIOUS"
TITLE="readline_add_history"
HREF="function.readline-add-history.html"><LINK
REL="NEXT"
TITLE="readline_callback_handler_remove"
HREF="function.readline-callback-handler-remove.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"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.readline-add-history.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.readline-callback-handler-remove.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.readline-callback-handler-install"
></A
>readline_callback_handler_install</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN192319"
></A
><P
>    (PHP 5 &#62;= 5.1.0RC1)</P
>readline_callback_handler_install&nbsp;--&nbsp;Initializes the readline callback interface and terminal, prints the prompt and returns immediately</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN192322"
></A
><H2
>Descrição</H2
>bool <B
CLASS="methodname"
>readline_callback_handler_install</B
> ( string prompt, callback callback )<BR
></BR
><P
>&#13;   Sets up a readline callback interface then prints
   <CODE
CLASS="parameter"
>prompt</CODE
> and immediately returns.  
   Calling this function twice without removing the previous
   callback interface will automatically and conveniently overwrite the old
   interface.
  </P
><P
>&#13;   The callback feature is useful when combined with
   <A
HREF="function.stream-select.html"
><B
CLASS="function"
>stream_select()</B
></A
> as it allows interleaving of IO and
   user input, unlike <A
HREF="function.readline.html"
><B
CLASS="function"
>readline()</B
></A
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN192338"
></A
><H2
>Parâmetros</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>prompt</CODE
></DT
><DD
><P
>&#13;       The prompt message.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>callback</CODE
></DT
><DD
><P
>&#13;       The <CODE
CLASS="parameter"
>callback</CODE
> function takes one parameter; the
       user input returned.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN192353"
></A
><H2
>Valores de retornado</H2
><P
>&#13;   Retorna <TT
CLASS="constant"
><B
>TRUE</B
></TT
> em caso de sucesso ou <TT
CLASS="constant"
><B
>FALSE</B
></TT
> em falhas.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN192358"
></A
><H2
>Exemplos</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN192361"
></A
><P
><B
>Exemplo 1. Readline Callback Interface Example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">function </font><font color="#0000BB">rl_callback</font><font color="#007700">(</font><font color="#0000BB">$ret</font><font color="#007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;global </font><font color="#0000BB">$c</font><font color="#007700">, </font><font color="#0000BB">$prompting</font><font color="#007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"You entered: $ret</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$c</font><font color="#007700">++;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$c </font><font color="#007700">&gt; </font><font color="#0000BB">10</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$prompting </font><font color="#007700">= </font><font color="#0000BB">false</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">readline_callback_handler_remove</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">readline_callback_handler_install</font><font color="#007700">(</font><font color="#DD0000">"</font><font color="#007700">[</font><font color="#DD0000">$c</font><font color="#007700">]</font><font color="#DD0000"> Enter something: "</font><font color="#007700">, </font><font color="#DD0000">'rl_callback'</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></font><font color="#0000BB">$c </font><font color="#007700">= </font><font color="#0000BB">1</font><font color="#007700">;<br /></font><font color="#0000BB">$prompting </font><font color="#007700">= </font><font color="#0000BB">true</font><font color="#007700">;<br /><br /></font><font color="#0000BB">readline_callback_handler_install</font><font color="#007700">(</font><font color="#DD0000">"</font><font color="#007700">[</font><font color="#DD0000">$c</font><font color="#007700">]</font><font color="#DD0000"> Enter something: "</font><font color="#007700">, </font><font color="#DD0000">'rl_callback'</font><font color="#007700">);<br /><br />while (</font><font color="#0000BB">$prompting</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$w </font><font color="#007700">= </font><font color="#0000BB">NULL</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$e </font><font color="#007700">= </font><font color="#0000BB">NULL</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">$n </font><font color="#007700">= </font><font color="#0000BB">stream_select</font><font color="#007700">(</font><font color="#0000BB">$r </font><font color="#007700">= array(</font><font color="#0000BB">STDIN</font><font color="#007700">), </font><font color="#0000BB">$w</font><font color="#007700">, </font><font color="#0000BB">$e</font><font color="#007700">, </font><font color="#0000BB">null</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$n </font><font color="#007700">&amp;&amp; </font><font color="#0000BB">in_array</font><font color="#007700">(</font><font color="#0000BB">STDIN</font><font color="#007700">, </font><font color="#0000BB">$r</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000">// read a character, will call the callback when a newline is entered<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">readline_callback_read_char</font><font color="#007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />echo </font><font color="#DD0000">"Prompting disabled. All done.\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN192364"
></A
><H2
>Veja também</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.readline-callback-handler-remove.html"
><B
CLASS="function"
>readline_callback_handler_remove()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.readline-callback-read-char.html"
><B
CLASS="function"
>readline_callback_read_char()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.stream-select.html"
><B
CLASS="function"
>stream_select()</B
></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.readline-add-history.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.readline-callback-handler-remove.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>readline_add_history</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.readline.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>readline_callback_handler_remove</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>