News for hackers. Stuff that matters.
Re:PHP: The Right Way by _ikke_ on Sunday July 08, 2012 @07:38AM (#4214362)
There's a fine line between filtering and validating. What's meant with filtering is things like add_slashes and mysql_real_escape_string, a uniform transformation on the input, regardless of it's destination.

Validating on the other hand is checking if the values satisfy the expected requirements.

You only want to apply certain filters if you know they apply the current output. (htmlentities if output as html, mysql_real_escape_string if embedded in a query).

Re:PHP: The Right Way by smsm42 on Monday July 09, 2012 @04:19AM (#4217201)
Filtering can't be done "regardless of destination", of course, since kind of filtering depends on the required result. Otherwise, difference between filtering and validation is largely in application semantics - some may prefer one, some another. Output is different things, of course filters can be applied to the output too.