|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-14 18:46 UTC] ramsey@php.net
Description: ------------ When using the FL_BOOLEAN filter, one is restricted to only "on", "off", "true", or "false". It would be nice to support multiple cases of these (i.e. On, Off, ON, OFF, TRUE, FALSE); (I have a patch for this that I will submit.) Reproduce code: --------------- <?php $boolTrue = "True"; $boolFalse = "FALSE"; var_dump(filter_data($boolTrue, FL_BOOLEAN)); var_dump(filter_data($boolFalse, FL_BOOLEAN)); ?> Expected result: ---------------- bool(true) bool(false) Actual result: -------------- NULL NULL PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
Index: logical_filters.c =================================================================== RCS file: /repository/pecl/filter/logical_filters.c,v retrieving revision 1.8 diff -u -u -r1.8 logical_filters.c --- logical_filters.c 28 Sep 2005 09:14:43 -0000 1.8 +++ logical_filters.c 14 Nov 2005 23:23:49 -0000 @@ -169,14 +169,14 @@ /* returns true for "1", "true" and "on", * returns false for "0", "false" and "off", "" and * null otherwise. */ - if ((strcmp(Z_STRVAL_P(value), "true") == 0) || - (strcmp(Z_STRVAL_P(value), "on") == 0) || + if ((strcasecmp(Z_STRVAL_P(value), "true") == 0) || + (strcasecmp(Z_STRVAL_P(value), "on") == 0) || (strcmp(Z_STRVAL_P(value), "1") == 0)) { Z_TYPE_P(value) = IS_BOOL; Z_LVAL_P(value) = 1; - } else if ((strcmp(Z_STRVAL_P(value), "false") == 0) || - (strcmp(Z_STRVAL_P(value), "off") == 0) || + } else if ((strcasecmp(Z_STRVAL_P(value), "false") == 0) || + (strcasecmp(Z_STRVAL_P(value), "off") == 0) || (strcmp(Z_STRVAL_P(value), "0") == 0)) { Z_TYPE_P(value) = IS_BOOL;