./sapi/cli/php -r 'var_dump(is_int("jkhdsjh"));'
bool(false)

./sapi/cli/php -v
PHP 5.1.2-dev (cli)

What am I doing wrong?

On 29.11.2005 18:57, Gareth Ardron wrote:
Hi.

Think I've just stumbled upon a possible bug with is_int.

if you've got the following code:

<form action='1.php' method='post'>
<input type='text' name='days'>
<input type='submit' name='submit' value='submit'>
</form>
<?php
if (!is_int($_REQUEST['days']) || $_REQUEST['days'] < 0) {
        $_REQUEST['days'] = 10;
}
print "<br>days::".$_REQUEST['days'];
?>

and somebody enters, say "jkhdsjh" into the form, is_int() returns 1, thereby not setting the $_REQUEST['days'] variable to 10 - if I switch to using is_numeric then everything works as it should. Obviously, this isn't ideal as somebody could then enter 2.5 rather than the integers that I want to be passed.

Looking at the source, this is in ext/standard/type.c in the php_is_type() function which seems to be messing up.

Can anybody confirm this is:
a) undesired behaviour and I'm not just being very "special" and
b) that this is happening. I've tried on two boxes with 5.1.1[0] but it'd help to get somebody else's opinion

If it's a bug, I'll do a patch up later tonight - just want to get it confirmed first.

Cheers.



--
Wbr, Antony Dovgal

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to