Back to index

php5  5.3.10
input_get_args.php
Go to the documentation of this file.
00001 <?php
00002 error_reporting(E_ALL|E_STRICT);
00003 $data = array(
00004     'product_id'     => 'product id<script>',
00005     'component'             => '10',
00006     'versions'              => '1.2.33',
00007        'testscalar'  => array('2','23','10','12'),
00008        'testarray'          => '2',
00009 );
00010 
00011 $args = array(
00012     'product_id'    => FILTER_SANITIZE_ENCODED,
00013     'component'     => array('filter'     => FILTER_VALIDATE_INT,
00014                                                   'flags'      => FILTER_FLAG_ARRAY,
00015                                                   'options'    => array("min_range"=>1, "max_range"=>10)
00016                                           ),
00017 
00018        /* equivalent of => FILTER_SANITIZE_ENCODED as SCALAR is
00019         * the default mode
00020      */
00021     'versions'      => array(
00022                             'filter' => FILTER_SANITIZE_ENCODED,
00023                             'flags'  => FILTER_FLAG_SCALAR,
00024                                                  ),
00025        'doesnotexist'       => FILTER_VALIDATE_INT,
00026        'testscalar'  => FILTER_VALIDATE_INT,
00027        'testarray'   => array(
00028                                                  'filter' => FILTER_VALIDATE_INT,
00029                                                  'flags'  => FILTER_FLAG_ARRAY,
00030                                           )
00031 
00032 );
00033 
00034 /*
00035 The other INPUT_* can be used as well.
00036 $myinputs = input_get_args($args, INPUT_POST);
00037 */
00038 $myinputs = input_get_args($args, INPUT_DATA, $data);
00039 
00040 var_dump($myinputs);
00041