Forum Moderators: coopster

Message Too Old, No Replies

escaping characters

         

DrDoc

8:03 pm on Apr 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I want to escape certain characters, and apply this to every element in the $_POST array, is an array walk the best way to do it?

Also, is addslashes() sufficient?

grahamstewart

12:25 am on Apr 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I prefer the foreach() structure because I find it more readable (no need to hunt around for the callback function). But I guess either would do, its not like its a very big array so it won't make any odds to performance.

is addslashes() sufficient?

Depends what you want to do with the data.
if your just sticking it into a database then yeah, addslashes should be fine.

If your displaying it again later then you might also want to consider the htmlspecialchars function.