Sophie

Sophie

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

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
>filter_input_array</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="Filter Functions"
HREF="ref.filter.html"><LINK
REL="PREVIOUS"
TITLE="filter_id"
HREF="function.filter-id.html"><LINK
REL="NEXT"
TITLE="filter_input"
HREF="function.filter-input.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.filter-id.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.filter-input.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.filter-input-array"
></A
>filter_input_array</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN51486"
></A
><P
>    (no version information, might be only in CVS)</P
>filter_input_array&nbsp;--&nbsp;Gets multiple variables from outside PHP and optionally filters them</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN51489"
></A
><H2
>Descrição</H2
>mixed <B
CLASS="methodname"
>filter_input_array</B
> ( int type [, mixed definition] )<BR
></BR
><P
>&#13;   This function is useful for retrieving many values without
   repetitively calling <A
HREF="function.filter-input.html"
><B
CLASS="function"
>filter_input()</B
></A
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN51502"
></A
><H2
>Parâmetros</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>type</CODE
></DT
><DD
><P
>&#13;       One of <TT
CLASS="constant"
><B
>INPUT_GET</B
></TT
>, <TT
CLASS="constant"
><B
>INPUT_POST</B
></TT
>,
       <TT
CLASS="constant"
><B
>INPUT_COOKIE</B
></TT
>, <TT
CLASS="constant"
><B
>INPUT_SERVER</B
></TT
>,
       <TT
CLASS="constant"
><B
>INPUT_ENV</B
></TT
>, <TT
CLASS="constant"
><B
>INPUT_SESSION</B
></TT
>, or
       <TT
CLASS="constant"
><B
>INPUT_REQUEST</B
></TT
>.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>definition</CODE
></DT
><DD
><P
>&#13;       An array defining the arguments. A valid key is a <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
>
       containing a variable name and a valid value is either a filter type,
       or an <A
HREF="language.types.array.html"
><B
CLASS="type"
>array</B
></A
> optionally specifying the filter, flags and
       options. If the value is an array, valid keys are
       <TT
CLASS="literal"
>filter</TT
> which specifies the filter type,
       <TT
CLASS="literal"
>flags</TT
> which specifies any flags that apply to the
       filter, and <TT
CLASS="literal"
>options</TT
> which specifies any options
       that apply to the filter. See the example below for a better
       understanding.
      </P
><P
>&#13;       This parameter can be also an integer holding a <A
HREF="ref.filter.html#filter.intro"
>filter constant</A
>. Then all values in the
       input array are filtered by this filter.
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN51530"
></A
><H2
>Valores de retornado</H2
><P
>&#13;   An array containing the values of the requested variables on success, or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> 
   on failure. An array value will be <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if the filter fails, or <TT
CLASS="constant"
><B
>NULL</B
></TT
> if 
   the variable is not set. Or if the flag <TT
CLASS="constant"
><B
>FILTER_NULL_ON_FAILURE</B
></TT
>
   is used, it returns <TT
CLASS="constant"
><B
>FALSE</B
></TT
> if the variable is not set and <TT
CLASS="constant"
><B
>NULL</B
></TT
> if the filter 
   fails.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN51539"
></A
><H2
>Exemplos</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN51542"
></A
><P
><B
>Exemplo 1. A <B
CLASS="function"
>filter_input_array()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />error_reporting</font><font color="#007700">(</font><font color="#0000BB">E_ALL </font><font color="#007700">| </font><font color="#0000BB">E_STRICT</font><font color="#007700">);<br /></font><font color="#FF8000">/* data actually came from POST<br />$_POST = array(<br />&nbsp;&nbsp;&nbsp;&nbsp;'product_id'&nbsp;&nbsp;&nbsp;&nbsp;=&gt; 'libgd&lt;script&gt;',<br />&nbsp;&nbsp;&nbsp;&nbsp;'component'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; '10',<br />&nbsp;&nbsp;&nbsp;&nbsp;'versions'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; '2.0.33',<br />&nbsp;&nbsp;&nbsp;&nbsp;'testscalar'&nbsp;&nbsp;&nbsp;&nbsp;=&gt; array('2', '23', '10', '12'),<br />&nbsp;&nbsp;&nbsp;&nbsp;'testarray'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; '2',<br />);<br />*/<br /><br /></font><font color="#0000BB">$args </font><font color="#007700">= array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'product_id'&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_SANITIZE_ENCODED</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'component'&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; array(</font><font color="#DD0000">'filter'&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_VALIDATE_INT</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'flags'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_FLAG_ARRAY</font><font color="#007700">, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'options'&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; array(</font><font color="#DD0000">'min_range' </font><font color="#007700">=&gt; </font><font color="#0000BB">1</font><font color="#007700">, </font><font color="#DD0000">'max_range' </font><font color="#007700">=&gt; </font><font color="#0000BB">10</font><font color="#007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'versions'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_SANITIZE_ENCODED</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'doesnotexist' </font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_VALIDATE_INT</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'testscalar'&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'filter' </font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_VALIDATE_INT</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'flags'&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_FLAG_SCALAR</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'testarray'&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">=&gt; array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'filter' </font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_VALIDATE_INT</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'flags'&nbsp;&nbsp;</font><font color="#007700">=&gt; </font><font color="#0000BB">FILTER_FLAG_ARRAY</font><font color="#007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br /><br />);<br /><br /></font><font color="#0000BB">$myinputs </font><font color="#007700">= </font><font color="#0000BB">filter_input_array</font><font color="#007700">(</font><font color="#0000BB">INPUT_POST</font><font color="#007700">, </font><font color="#0000BB">$args</font><font color="#007700">);<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$myinputs</font><font color="#007700">);<br />echo </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>O exemplo acima irá imprimir:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>array(6) {
  ["product_id"]=&#62;
  array(1) {
    [0]=&#62;
    string(17) "libgd%3Cscript%3E"
  }
  ["component"]=&#62;
  array(1) {
    [0]=&#62;
    int(10)
  }
  ["versions"]=&#62;
  array(1) {
    [0]=&#62;
    string(6) "2.0.33"
  }
  ["doesnotexist"]=&#62;
  NULL
  ["testscalar"]=&#62;
  bool(false)
  ["testarray"]=&#62;
  array(1) {
    [0]=&#62;
    int(2)
  }
}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN51548"
></A
><H2
>Veja também</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.filter-input.html"
><B
CLASS="function"
>filter_input()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.filter-var-array.html"
><B
CLASS="function"
>filter_var_array()</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.filter-id.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.filter-input.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>filter_id</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.filter.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>filter_input</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>