Posted inphp

PHP htmlspecialchars() Function

Today, We want to share with you htmlspecialchars.In this post we will show you htmlspecialchar vs htmlentities, hear for htmlspecialchar javascript we will give you demo and example for implement.In this post, we will learn about How To Remove All Special Characters From A String In Php? with an example.

HTML Encoding With htmlspecialchar and htmlentities

  • & (ampersand) converted as &
  • (double quote) converted as "
  • (single quote) converted as '
  • < (less than) converted as &lt;
  • > (greater than) converted as &gt;

PHP Function

echo htmlspecialchars($str, ENT_QUOTES); // Converts double and single quotes
echo "
"; echo htmlspecialchars($str, ENT_NOQUOTES); // Does not convert any quotes ?>

PHP : function

Welcome To Free Download Source code php";
echo "Original string : ".$convert;
echo "
"; htmlspecialchars("
  • Welcome To Free Download Source code php
  • ", ENT_QUOTES); echo "Only HTML special characters : ".htmlspecialchars($convert); ?>

    PHP String Function

    pakainfo text.";  
    echo htmlspecialchars($str, ENT_QUOTES);    //Will convert both single and double-quotes.  

    I hope you get an idea about PHP htmlspecialchar Function.
    I would like to have feedback on my blog.
    Your valuable feedback, question, or comments about this article are always welcome.
    If you enjoyed and liked this post, don’t forget to share.

    I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype