htmlentities — Convert all applicable characters to HTML entities

  1. <html>  
  2.  <body>  
  3. <?php
  4. $str = “A ‘quote’ is <b>bold</b>”;
  5. // Outputs: A ‘quote’ is &lt;b&gt;bold&lt;/b&gt;
  6. echo htmlentities($str);
  7. // Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
  8. echo htmlentities style=”color: #007700;”>($str, ENT_QUOTES);
  9. ?>
  10. htmlspecialchars much should i take — Convert special characters to HTML entities
  11. <?php
  12. $new = htmlspecialchars(“<a href=’test’>Test</a>”, ENT_QUOTES);
  13. echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
  14. ?>
  15.  </body>   
  16. </html>  
eXTReMe Tracker