Search notes:

PHP code snippets: the htmlspecialchars function

htmlspecialchars converts characters that have a meaning in HTML to HTML character entities.
For example, a & is turned into a &amp;, or a < into a &lt;.
<html><head><title>htmlspecialchars</title></head>
<body>

  <?php 
   

    $html_snippet = "Now, for <i>something</i> very <b>bold</b>!";

    echo '$html_snippet: ' . $html_snippet . "<br>";
    echo 'htmlspecialchars($html_snippet): ' . htmlspecialchars($html_snippet) . "<br>";


  ?>

  <p>See also <a href='strip_tags.html'>strip_tags.html</a> and <a href='form_handling.html'>form_handling.html</a>.
    
</body>
</html>
Github repository about-php, path: /htmlspecialchars.html

See also

Compare with
Other PHP snippets.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740101627, '18.220.95.15', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/php/snippets/htmlspecialchars(67): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78