Fix #42608: Example 660 (filter_input_array) is wrong

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@344963 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2018-05-05 16:24:41 +00:00
parent 0dfd64fc2a
commit dc157b93cd

View file

@ -67,11 +67,17 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An array containing the values of the requested variables on success, or &false;
on failure. An array value will be &false; if the filter fails, or &null; if
An array containing the values of the requested variables on success.
If the input array designated by <parameter>type</parameter> is not populated,
the function returns &null; if the <constant>FILTER_NULL_ON_FAILURE</constant>
flag is not given, or &false; otherwise. For other failures, &false; is returned.
</para>
<para>
An array value will be &false; if the filter fails, or &null; if
the variable is not set. Or if the flag <constant>FILTER_NULL_ON_FAILURE</constant>
is used, it returns &false; if the variable is not set and &null; if the filter
fails.
fails. If the <parameter>add_empty</parameter> parameter is &false;, no array
element will be added for unset variables.
</para>
</refsect1>
@ -87,10 +93,10 @@ error_reporting(E_ALL | E_STRICT);
/* data actually came from POST
$_POST = array(
'product_id' => 'libgd<script>',
'component' => '10',
'versions' => '2.0.33',
'testscalar' => array('2', '23', '10', '12'),
'testarray' => '2',
'component' => array('10'),
'version' => '2.0.33',
'testarray' => array('2', '23', '10', '12'),
'testscalar' => '2',
);
*/
@ -100,7 +106,7 @@ $args = array(
'flags' => FILTER_REQUIRE_ARRAY,
'options' => array('min_range' => 1, 'max_range' => 10)
),
'versions' => FILTER_SANITIZE_ENCODED,
'version' => FILTER_SANITIZE_ENCODED,
'doesnotexist' => FILTER_VALIDATE_INT,
'testscalar' => array(
'filter' => FILTER_VALIDATE_INT,
@ -131,16 +137,22 @@ array(6) {
[0]=>
int(10)
}
["versions"]=>
["version"]=>
string(6) "2.0.33"
["doesnotexist"]=>
NULL
["testscalar"]=>
bool(false)
int(2)
["testarray"]=>
array(1) {
array(4) {
[0]=>
int(2)
[1]=>
int(23)
[2]=>
int(10)
[3]=>
int(12)
}
}
]]>