#41305 [Opn->Csd]: BOOLEAN acts strange

From: Date: Sun, 17 Jun 2007 11:56:08 +0000
Subject: #41305 [Opn->Csd]: BOOLEAN acts strange
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969376761@lists.php.net to get a copy of this message
ID: 41305 Updated by: gwynne@php.net Reported By: Se dot Krebs at web dot de -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Win32 PHP Version: 5.2.2 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2007-05-07 20:53:19] tony2001@php.net Both Ilia & Derick said it's a docu problem. Reclassified. ------------------------------------------------------------------------ [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 (#969376761) next »