Re: is_int/is_numeric possible bug

From: Date: Tue, 29 Nov 2005 18:33:37 +0000
Subject: Re: is_int/is_numeric possible bug
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-20859@lists.php.net to get a copy of this message
If you're having that problem that a request variable is being reported as an integer, I suggest using var_dump(). That function will tell you the type and contents of a variable. For example: $bool = true; $int = 1; $float = 1.0; $str = 'abc'; $array = array(); var_dump($bool, $int, $float, $str, $array); Will give you: bool(true) int(1) float(1) string(3) "abc" array(0) { } All of the above are very different. A request variable should always be of type string, and if one is not then I suspect that may indeed be a bug. Remember that PHP doesn't hide the type from you, it just simplifies conversions and usage for you. In any case, if you want it to be 10 if it wasn't set to a valid int, I think you want: $_REQUEST['days'] = is_numeric($_REQUEST['days']) ? (int) $_REQUEST['days'] : 10; Or similar. Note that this will treat "5.1" as 5, not as 10 (which may be what you want.) -[Unknown] -------- Original Message --------
Antony Dovgal wrote:
And PHP from .deb too? *That* could be a problem.
God no, If I was doing that, I wouldn't report the bug here :) Can give you the configure line if it'll help?


« previous php.internals (#20859) next »