|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-08-13 05:21 UTC] 498936940 at qq dot com
Description:
------------
---
var_dump(
filter_input_array(
INPUT_GET,
[
'id' => [
'filter' => FILTER_CALLBACK,
'options' => function($v){return $v;},
'flags' => FILTER_REQUIRE_SCALAR,
]
]
)
);
exit();
/?id=2
array(1) {
["id"]=>
string(1) "2"
}
/?id[]=3&id[]=4
array(1) {
["id"]=>
array(2) {
[0]=>
string(1) "3"
[1]=>
string(1) "4"
}
}
---
I must limit ID must be scalar, not array, filter cannot control!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
Flags are not used with FILTER_CALLBACK. 'id' => [ 'filter' => FILTER_CALLBACK, 'options' => function($v){ return is_scalar($v) ? $v : null; }, ]··· var_dump( filter_input_array( INPUT_GET, [ 'id' => [ 'filter' => FILTER_CALLBACK, 'options' => function($v){ return is_scalar($v) ? $v : null; } ] ] ) ); exit(); /?id=2 array(1) { ["id"]=> string(1) "2" } /?id[]=3&id[]=4 array(1) { ["id"]=> array(2) { [0]=> string(1) "3" [1]=> string(1) "4" } } ··· I must limit ID must be scalar, not array, filter cannot control!