php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52813 Filter Vars Missing Types (Update Types)
Submitted: 2010-09-10 16:46 UTC Modified: 2015-01-18 04:22 UTC
From: takingsides at gmail dot com Assigned:
Status: No Feedback Package: Filter related
PHP Version: * OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-09-10 16:46 UTC] 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)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 15:28 UTC] jani@php.net
-Package: Unknown/Other Function +Package: Filter related
 [2010-12-01 15:28 UTC] jani@php.net
-Operating System: Irrelevant +Operating System: -PHP Version: Irrelevant +PHP Version: *
 [2015-01-10 21:55 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2015-01-10 21:55 UTC] danack@php.net
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.
 [2015-01-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 26 17:01:27 2019 UTC