ID:               41305
 Updated by:       [EMAIL PROTECTED]
 Reported By:      Se dot Krebs at web dot de
 Status:           Open
-Bug Type:         Filter related
+Bug Type:         Documentation problem
 Operating System: Win32
 PHP Version:      5.2.2
 New Comment:

Both Ilia & Derick said it's a docu problem.
Reclassified.


Previous Comments:
------------------------------------------------------------------------

[2007-05-06 18:13:56] Se dot Krebs at web dot de

Description:
------------
FILTER_VALIDATE_BOOLEAN never returns null like its mentioned in the
Manual ("otherwise null") without the FILTER_NULL_ON_FAILURE-Option.
Even in the Manual is mentioned, that only String-"Booleans" will
filterd, but true also returns true.

Maybe without the Option the Manual is a kind of out-of-date, but the
fact, that "false" is a Failure, but "true" isnt, seems strange to me.

Reproduce code:
---------------
var_dump( filter_var('false', FILTER_VALIDATE_BOOLEAN));
var_dump( filter_var(false, FILTER_VALIDATE_BOOLEAN));
var_dump( filter_var('true', FILTER_VALIDATE_BOOLEAN));
var_dump( filter_var(true, FILTER_VALIDATE_BOOLEAN));

var_dump( filter_var('false', FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE)); // bool(false)
var_dump( filter_var(false, FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE)); // NULL
var_dump( filter_var('true', FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE)); // bool(false)
var_dump( filter_var(true, FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE)); // bool(false)

Expected result:
----------------
// first 4 lines:
bool (false)
NULL
bool (true)
NULL

// last 4 lines the same


Actual result:
--------------
bool (false)
bool (false)
bool (true)
bool (true)

bool (false)
NULL
bool (true)
bool (true)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41305&edit=1

Reply via email to