#50632 [Opn->Csd]: Return default value if var is undefined
| From: | iliaa@php.net | Date: | Sun, 03 Jan 2010 22:58:48 +0000 |
| Subject: | #50632 [Opn->Csd]: Return default value if var is undefined | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146297@lists.php.net to get a copy of this message | ||
ID: 50632
Updated by: iliaa@php.net
Reported By: gmblar+php at gmail dot com
-Status: Open
+Status: Closed
Bug Type: Filter related
Operating System: *
PHP Version: 5.3.1
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2010-01-03 22:58:38] svn@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=293051
Log: Fixed bug #50632 (filter_input() does not return default value if
the variable does not exist)
------------------------------------------------------------------------
[2010-01-02 09:38:41] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50632&edit=1