Imagine you're building a feedback form where users can submit comments. To prevent potential script injections, which PHP function would you use to process the comment text before displaying it back to other users or saving it to a database?
- htmlentities()
- urlencode()
- strip_tags()
- base64_encode()
The htmlentities() function is used to convert potentially harmful characters in user input to their HTML entities, preventing script injections. It's a security measure to sanitize user-generated content.
Loading...
Related Quiz
- What is the purpose of the array_pop() function in PHP?
- You want to execute some code in your PHP script if a certain condition is not met. How would you do this using an else statement?
- The filter_input_array() function is used to get multiple input values and optionally filter them in PHP.
- The is_numeric() function in PHP checks if a variable is a(n) ______.
- What is the default session time in PHP?