I've just updated my PHP version from 8.0.26 to 8.2.0 and I know have to deal with the deprecated FILTER_SANITIZE_STRING
constant. I was using it this way to filter some text inputs in a form in order to protect a website from SQL injections. :
$text_input_value = filter_var($_POST['a_text_input'], FILTER_SANITIZE_STRING);
I know it'll still work for a while yet, but I don't like at all to use deprecated code. And yet I just heard that FILTER_SANITIZE_STRING
determined an unclear purpose and the PHP community decided that his filter shouldn't be supported anymore.
I can't find any solution on the Internet as everyone seemed to use the FILTER_SANITIZE_STRING
for something else than protecting against SQL injections. They seemed to rather use it to protect against XSS attacks.
So, my question is, what should I use now to replace this filter/sanitize my inputs from any SQL injection ? Feel free to tell me if I was using a wrong way to sanitize my inputs. (I'm also using prepared SQL statement into my PHP script, but I'm not sure if it's enough to secure against SQL injections, or if inputs sanitizing is also necessary.)