flaw in php ?
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: flaw in php ?
So do you want 0 to match 'zero' or do you want '0' to match 'zero' ? Or do you not want them to match at all?
Re: flaw in php ?
@kai. who are you asking ?
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: flaw in php ?
You.php_east wrote:@kai. who are you asking ?
Re: flaw in php ?
well then i think you got the wrong number mate, it's Mark's code, not mine. i'm the one who showed him the flaw. he is the flawee
. but he says he is ok with it, so ask him if you want.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: flaw in php ?
The problem I had was that in_array defaults to loose type checking, so that numeric 0 was returning true with the in_array(), and acting out Case 1, when I actually needed it to fall into the Case 2 logic. Fortunately, in_array() accepts the optional third parameter to use strict checking, which gives me the correct result.
But it took me a lot of furtling around to identify that the in_array() test was the cause of my problem - writing a lexical parser isn't the easiest of tasks for debugging given the number of possible permutations of mathematical formulae - and even that it only gave incorrect results when my formulae included a function that takes no arguments (the 0 in question being the number of arguments).
But it took me a lot of furtling around to identify that the in_array() test was the cause of my problem - writing a lexical parser isn't the easiest of tasks for debugging given the number of possible permutations of mathematical formulae - and even that it only gave incorrect results when my formulae included a function that takes no arguments (the 0 in question being the number of arguments).