xref: /PHP-7.2/ext/filter/docs/input_get_args.php (revision 60a69dae)
1<?php
2error_reporting(E_ALL|E_STRICT);
3$data = array(
4    'product_id'	=> 'product id<script>',
5    'component'		=> '10',
6    'versions'		=> '1.2.33',
7	'testscalar'	=> array('2','23','10','12'),
8	'testarray'		=> '2',
9);
10
11$args = array(
12    'product_id'    => FILTER_SANITIZE_ENCODED,
13    'component'     => array('filter'	=> FILTER_VALIDATE_INT,
14							 'flags'	=> FILTER_FLAG_ARRAY,
15							 'options'	=> array("min_range"=>1, "max_range"=>10)
16						),
17
18	/* equivalent of => FILTER_SANITIZE_ENCODED as SCALAR is
19	 * the default mode
20     */
21    'versions'      => array(
22                            'filter' => FILTER_SANITIZE_ENCODED,
23                            'flags'  => FILTER_FLAG_SCALAR,
24							),
25	'doesnotexist'	=> FILTER_VALIDATE_INT,
26	'testscalar'	=> FILTER_VALIDATE_INT,
27	'testarray'	=> array(
28							'filter' => FILTER_VALIDATE_INT,
29							'flags'  => FILTER_FLAG_ARRAY,
30						)
31
32);
33
34/*
35The other INPUT_* can be used as well.
36$myinputs = input_get_args($args, INPUT_POST);
37*/
38$myinputs = input_get_args($args, INPUT_DATA, $data);
39
40var_dump($myinputs);
41