What does the mysqli_real_escape_string() function in PHP do?
Correct answer
B. Escapes special characters in a string for use in a SQL statement
12 views
B. Escapes special characters in a string for use in a SQL statement
12 views
mysqli_real_escape_string() escapes special characters in a string for use in an SQL statement, taking the connection's character set into account. It was the traditional defence against SQL injection.
Today prepared statements with bound parameters are the recommended approach, but this function still appears in legacy code and in most PHP-MySQL tests.
For more solved questions like this one, see Computer Science MCQs on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.