What are the best PHP input sanitizing functions?

后端 未结 13 1818
抹茶落季
抹茶落季 2020-11-21 23:31

I am trying to come up with a function that I can pass all my strings through to sanitize. So that the string that comes out of it will be safe for database insertion. But t

13条回答
  •  萌比男神i
    2020-11-22 00:04

    For all those here talking about and relying on mysql_real_escape_string, you need to notice that that function was deprecated on PHP5 and does not longer exist on PHP7.

    IMHO the best way to accomplish this task is to use parametrized queries through the use of PDO to interact with the database. Check this: https://phpdelusions.net/pdo_examples/select

    Always use filters to process user input. See http://php.net/manual/es/function.filter-input.php

提交回复
热议问题