Req #52813 [Opn->Fbk]: Filter Vars Missing Types (Update Types)
Edit report at https://bugs.php.net/bug.php?id=52813&edit=1
ID: 52813
Updated by: danack@php.net
Reported by: takingsides at gmail dot com
Summary: Filter Vars Missing Types (Update Types)
-Status: Open
+Status: Feedback
Type: Feature/Change Request
Package: Filter related
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Hi,
Making this change would be a backwards compatibility break, as suddenly people who have code that
expects "T" and "Y" to produce false, would suddenly find their code was
behaving differently.
If you still think this behaviour change is a good idea, then you should discuss it as a change in
the PHP internals mailing list (http://php.net/mailing-lists.php) and then raise an RFC for the
change to be made.
Previous Comments:
------------------------------------------------------------------------
[2010-09-10 16:46:16] takingsides at gmail dot com
Description:
------------
I have been through one of the filter_vars() functions and have found some attributes missing from
the list...
The documentation states: "Returns TRUE for "1", "true", "on" and
"yes"."
However I feel this needs to be extended further to allocate two more attributes to be triggered at
"TRUE" there are...
"T" and "Y" (T = true, Y = Yes)
Test script:
---------------
<?php
$str = "1";
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: true
$str = "yes";
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: true
$str = "on";
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: true
$str = true;
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: true
// missing (potential bug):
$str = "t";
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: false (should be true, t = true)
$str = "y";
var_dump(filter_var($str, FILTER_VALIDATE_BOOLEAN)); // output: false (should be true, y = true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=52813&edit=1
Thread (3 messages)