Bug #71319 [Com]: FILTER_SANITIZE_NUMBER_FLOAT return float instead of string

From: Date: Tue, 12 Jan 2016 02:16:58 +0000
Subject: Bug #71319 [Com]: FILTER_SANITIZE_NUMBER_FLOAT return float instead of string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198592@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71319&edit=1 ID: 71319 Comment by: vadz77 at hotmail dot com Reported by: Cyb at Cyb10101 dot de Summary: FILTER_SANITIZE_NUMBER_FLOAT return float instead of string Status: Open Type: Bug Package: Filter related Operating System: Ubuntu 14.04 PHP Version: 5.5.31 Block user comment: N Private report: N New Comment: I don't think this is a bug. FILTER_SANITIZE_NUMBER_FLOAT should just sanitize a string and return as a string. E.g. http://codepad.org/T690Wdad Previous Comments: ------------------------------------------------------------------------ [2016-01-09 12:40:05] Cyb at Cyb10101 dot de Description: ------------ Hi, I'm not sure if that's a bug. The function filter_var($x, FILTER_SANITIZE_NUMBER_FLOAT) should not return a float instead string? Kind regards, Cyb10101 Test script: --------------- <?php function d($a = '', $x, $z = ' | ') {echo $a; var_dump($x); echo $z;} function run($x) { d('init=', $x); d('bool=', (filter_var($x, FILTER_VALIDATE_FLOAT) ? 'Valid' : 'Not Valid')); d('validate=', filter_var($x, FILTER_VALIDATE_FLOAT)); d('sanitize=', filter_var($x, FILTER_SANITIZE_NUMBER_FLOAT), "<br />\n"); } run(0.5); // init=float(0.5) | bool=string(5) "Valid" | validate=float(0.5) | sanitize=string(2) "05" run('0.5'); // init=string(3) "0.5" | bool=string(5) "Valid" | validate=float(0.5) | sanitize=string(2) "05" Expected result: ---------------- run(0.5); // ... | sanitize=float(0.5) run('0.5'); // ... | sanitize=float(0.5) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71319&edit=1

« previous php.bugs (#198592) next »