1. Home
  2. Computer Science MCQs
  3. PHP
  4. What does the mysqli_real_escape_string() function in PHP…

Added 23 Jan 2024

What does the mysqli_real_escape_string() function in PHP do?

  1. Escapes HTML characters in a string
  2. Escapes special characters in a string for use in a SQL statement Correct answer
  3. Converts a string to lowercase
  4. Validates an email address

Correct answer

B. Escapes special characters in a string for use in a SQL statement

12 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs