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
<?php

$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
<?php

$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.

No comments :

Post a Comment

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA
lessoncup@gmail.com

PHP | My SQL | JQUERY
Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons