How to convert characters to HTML entities in PHP

2 Answers

0 votes
$html = '<a href="collectivesolver.com">collectivesolver programming</a>';
echo htmlentities($html);
  
  
  
/*
run:

&lt;a href=&quot;collectivesolver.com&quot;&gt;collectivesolver programming&lt;/a&gt;

*/

 



answered Oct 14, 2019 by avibootz
0 votes
$html = "<p>'PHP'</p>";
echo htmlentities($html) . "<br />\n";
echo htmlentities($html, ENT_QUOTES);
  
  
/*
run:

&lt;p&gt;'PHP'&lt;/p&gt;<br />
&lt;p&gt;&#039;PHP&#039;&lt;/p&gt;

*/

 



answered Oct 14, 2019 by avibootz

Related questions

1 answer 200 views
2 answers 235 views
4 answers 491 views
3 answers 319 views
1 answer 195 views
...