|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-07 20:53 UTC] tony2001@php.net
[2007-06-17 11:56 UTC] gwynne@php.net
[2010-03-21 18:05 UTC] pravila at alumni dot calpoly dot edu
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 11:00:02 2025 UTC |
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)