What is the purpose of the htmlspecialchars() function in PHP?
- To convert special characters to HTML entities
- To remove HTML tags from a string
- To encode a URL
- To convert HTML entities to special characters
The htmlspecialchars() function in PHP is used to convert special characters to their corresponding HTML entities. This prevents the characters from being interpreted as HTML tags or entities when rendered in an HTML document. It helps prevent cross-site scripting (XSS) attacks. Learn more: http://php.net/manual/en/function.htmlspecialchars.php
Loading...
Related Quiz
- A constructor in a PHP class is defined using the __construct() method.
- The foreach loop in PHP is used exclusively for arrays.
- PHP code is enclosed in ______ and ______ tags.
- What are the differences between an abstract class and a regular class in PHP?
- How is the ternary conditional operator used in PHP?