Req #75229 [Opn]: FILTER_VALIDATE_INT should allow 0 prefixes

From: Date: Tue, 19 Sep 2017 16:15:41 +0000
Subject: Req #75229 [Opn]: FILTER_VALIDATE_INT should allow 0 prefixes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211253@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75229&edit=1 ID: 75229 Updated by: derick@php.net Reported by: thflori at gmail dot com Summary: FILTER_VALIDATE_INT should allow 0 prefixes Status: Open Type: Feature/Change Request Package: Filter related Operating System: Linux PHP Version: 7.1.9 Block user comment: N Private report: N New Comment: I don't believe we should change that. This filter is really for properly formatted numbers. Previous Comments: ------------------------------------------------------------------------ [2017-09-19 14:53:58] thflori at gmail dot com Description: ------------ Someone defined octal numbers are prefixed with a 0 but there is no mathematical theory that says a number with one or more 0 in front is not a number. When we now use filter_var to filter user input we have to tell the user that a number with 0 in front is not an integer. Or we use a more generic way like reg exp /^\d+$/ but I thought the filter_var is made for this propose. Currently the problem is that users enter minutes and seconds with zeroes in front. It should indeed not be a float so to filter for integer is correct. Test script: --------------- var_dump(filter_var('03', FILTER_VALIDATE_INT)); var_dump(filter_var('+08', FILTER_VALIDATE_INT)); var_dump(filter_var('-010', FILTER_VALIDATE_INT)); Expected result: ---------------- int(3) int(8) int(-10) Actual result: -------------- false false false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75229&edit=1

« previous php.bugs (#211253) next »