#41305 [Opn]: BOOLEAN acts strange

From: Date: Mon, 07 May 2007 20:53:19 +0000
Subject: #41305 [Opn]: BOOLEAN acts strange
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969376279@lists.php.net to get a copy of this message
ID: 41305 Updated by: tony2001@php.net 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

« previous php.doc (#969376279) next »