Page 3 of 3

Re: flaw in php ?

Posted: Thu Mar 12, 2009 1:30 pm
by kaisellgren
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 ?

Posted: Thu Mar 12, 2009 1:36 pm
by php_east
@kai. who are you asking ?

Re: flaw in php ?

Posted: Thu Mar 12, 2009 1:43 pm
by kaisellgren
php_east wrote:@kai. who are you asking ?
You.

Re: flaw in php ?

Posted: Thu Mar 12, 2009 2:02 pm
by php_east
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.

Re: flaw in php ?

Posted: Thu Mar 12, 2009 2:30 pm
by Mark Baker
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).