Out of experience which is better to use
filter_input(INPUT_GET, ‘my_string’, FILTER_SANITIZE_STRING);
Or a regular expression preg_match for sanitizing user in-putted data ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what you want to do and which PHP version you’re using.
filter_input is a convenient method to validate some input data for a well known target format such as URLs, IP-addresses or eMail-addresses, but might only be available for PHP >= 5.2.
In order to validate custom data (e.g. comma-separated values string), a regular expression would be more appropriate and therefore the way to go.