|
-
June 19th, 2008, 10:48 AM
#1
Bug in function, in_array()??
So...
This is user input:
PHP Code:
$range = array(2.55, 59.69);
This is parsed code:
PHP Code:
$okRange = array('min_range', 'max_range'); foreach($range as $k => $v) { if( in_array($k, $okRange) === false ) { echo "$k is invalid range flag!" . NL; } }
Response is:
HTML Code:
1 is invalid range flag!
But it was supposed to fail at: 0 is invalid range flag!
Why did int(0), passed through?!?
After I added a third param bool(true), to in_array(), then it worked like:
PHP Code:
... if( in_array($k, $okRange, true) === false ) ...
Bit it still doesn't make sense, why did int(0), passed through without third param bool(true)?!?
int(0), was compared to values 2.55 and 59.69.
So it was supposed to fail, like int(1) does!
Last edited by Ipsens; June 19th, 2008 at 10:54 AM.
Ipsens
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|