which sanitising function to use strongly depends on the context change, e.g.
- when using prepared statements, escaping for SQL is unnecessary
- htmlspecialchar s() is only for printing into HTML/XML and nothing else.
- strip_tags() is only against XSS
- a decently recent PHP installation doesn’t add slashes and stripping slashes off a windows directory name is not the best of ideas
- trimming a string is a bad idea if you need to retain whitespace
essentially, you always have to decide which sanitisation you need depending on the circumstances.
Comment