Return default value if var is undefined
| Bug #50632 | Return default value if var is undefined | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2010-01-02 09:38 UTC | Modified: | 2010-01-03 22:58 UTC |
|
||||||||||
| From: | gmblar+php at gmail dot com | Assigned: | ||||||||||||
| Status: | Closed | Package: | Filter related | |||||||||||
| PHP Version: | 5.3.1 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2010-01-02 09:38 UTC] gmblar+php at gmail dot com
Description:
------------
if $_GET['foo'] is undefined, filter functions return NULL instead of
the default value defined in options.
Reproduce code:
---------------
<?php
$foo = filter_input(INPUT_GET, 'foo', FILTER_VALIDATE_INT, array(
'flags' => FILTER_REQUIRE_SCALAR,
'options' => array(
'default' => 23,
'min_range' => 5,
'max_range' => 42
)
));
var_dump($foo);
?>
Expected result:
----------------
int(23)
Actual result:
--------------
NULL
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-01-03 22:58 UTC] iliaa@php.net