What is use of htmlentities function in PHP?

Last updated 5 years, 8 months ago | 2909 views 75     5

Tags:- PHP

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;

?>