$string = "Welcome to my website!"; $escaped_string = htmlentitiesutf8($string); echo $escaped_string; // output: <div>Welcome to my website!</div>
$string = "He said, \"I'm not sure what to do.\""; $escaped_string = htmlentitiesutf8($string, ENT_QUOTES); echo $escaped_string; // output: He said, "I'm not sure what to do."In this example, we have a string that contains quotes. By using the 'ENT_QUOTES' flag, both single and double quotes are escaped and replaced with their corresponding entities. Overall, the htmlentitiesutf8 function is a useful tool for ensuring that user-inputted text is properly escaped before being displayed on a web page. It is part of the PHP HTML Functions package library.