Here it checks to see if the given variable is a valid array. Well that about wraps it up for variable validation, there are more functions to use when it comes to validation but we will go into those later.
virtueCart v1.0.5 developed by WebDevSA
Last edited by quantumkangaroo : 03-20-2008 at 03:08 PM.
So be careful about using the is_* functions mentioned above blindly on user input as they might not behave precisely how you expect. For example, from the sample above, $_GET['foo'] is not a float and $_GET['bar'] is not boolean.
Also, the information provided about is_bool is incorrect. The function checks the data type of the variable so only $bool would return TRUE, the others would all return FALSE (go check for yourself).
It is also worth mentioning that is_numeric checks whether the variable is a number or a numeric string. For example, the following are all numeric but you might not want to allow them: "0123", "0xFF", "+123.4567e8".
I don't know if we're running different versions of PHP or something but I can't seem to correlate what you say with my results from sample code. is_numeric('fsda342') will return false, it's quite obvious that that string isn't a representation of a number. As for the user input comments, I only wrapped the values in quotes to denote that they were indeed strings rather than their integer/float counterparts.
As for is_bool, I've never had a problem with it and after a quick search I can't see any bugs filed for the function always returning true and it's certainly not expected behaviour. Does anyone else here have the same results?