Re: FILTER_VALIDATE_INT - newbie question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Also, I think you're getting confused over the zero with exactly what
> you are asking PHP to do. filter_var() returns true if the filter
> matches. If the 0 match is returned as a false, then filter_var() will

filter_var() actually returns the filtered data if the filter matches,
and FALSE if it doesn't. That's the whole point of the filter_XXX
functions; to pass a tainted value through a filter and get a clean,
"safe" value out the other end:

    $tainted = get_user_input();
    $clean = filter_var($tainted, [FILTER_CONSTANT]);
    // now use $clean and never touch $tainted again

>From the original code above, it looks like the OP was
misunderstanding the use of filter_var() and expecting it to return a
boolean.

Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux