Using PHP Htmlentities | Lessoncup Programming Blog

Thursday, 28 November 2013

Using PHP Htmlentities

Hi, today i going to tell you about most useful function in php that is htmlentities() this function convert the special characters into HTML entities, whenever you giving chance to user to enter something in text boxes you should think about security because we don't know every user give good text, but some users can play with your form.. :-) so to avoid this things and face them you must use htmlentites() function. 

see the bellow examples

$message = $_POST['message'];

if i enter some alert script in message box in webpage the alert box will display in you webpage while the page is loaded

$message = htmlentities($_POST['message']);

but here the above script will not effect to your webpage because we have used htmlentities() function to convert special characters into html entities

as we seen in FB, Google+ and other social network websites, we post scripts in comment box and share to others more over our scripts will not effect to their sites the reason is they are converting user given data into entities.

1 comment :

  1. I was getting bore since morning but as soon as I got this link & reached at this blog, I turned into fresh and also joyful too.
    branding firm in San Francisco


Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA

Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons