Re: ext/filter, add input_get_args, support of scalar or array result
| From: | Rasmus Lerdorf | Date: | Tue, 02 May 2006 06:42:05 +0000 |
| Subject: | Re: ext/filter, add input_get_args, support of scalar or array result | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23070@lists.php.net to get a copy of this message | ||
Pierre wrote:
I put a small example here: http://pecl.php.net/~pierre/filter_input_get_args_example.phps and the patch: http://pecl.php.net/~pierre/patch_filter_input_get_args.txtI think this looks ok. I have been trying to come up with a shorter and cleaner syntax to specify these things, but so far I haven't come up with anything I really like. The closest I have come is something like this: $args = array(
'product_id' => 'Enc',
'component' => 'Int:Array:1-10',
'versions' => 'Enc',
'doesnotexist' => 'Int',
'testscalar' => 'Int:Scalar',
'testarray' => 'Int:Array'
);
But I am not completely happy with the magic shortcuts in the strings there. The above would be equivalent to:
$args = array(
'product_id' => FILTER_SANITIZE_ENCODED,
'component' => array('filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FLAG_ARRAY,
'options' => array("min_range"=>1, "max_range"=>10)
),
'versions' => FILTER_SANITIZE_ENCODED,
'doesnotexist' => FILTER_VALIDATE_INT,
'testscalar' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FLAG_SCALAR,
),
'testarray' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FLAG_ARRAY,
)
);
-Rasmus