What is use of htmlentities function in PHP?

18 Views

What is use of htmlentities function in PHP?

htmlentities()

The htmlentities() function is used to convert all applicable characters to HTML entities.

 
 <?php

$str = '<a href="http://www.studyzone4u.com">Let's GO</a>';

echo htmlentities($str);

// output will be (source code)

&lt;a href=&quot; http://www.studyzone4u.com &quot;&gt;Let's GO&lt;/a&gt;

?>

 

Tags:-
PHP