You want to convert the HTML character into their corresponding HTML entities.
FOr that you can Use Functions
- htmlentities ()
- htmlspecialchars()
Form Having Text area
<form action="" method="POST">
<textarea name="address"></textarea>
<input type="submit" >
PHP part
<?php
$a = htmlentities($_POST[' address']);
echo $a;
//or
$b = htmlspecialchars($_POST[' address']);
echo $b;
//If you want to convert those entities back into HTML character
echo html_entity_decode($a);
echo "</br>";
echo html_entity_decode($b);
Now if you ask which one will be best then ..
htmlentities() can translate anything as listed in Manual
while htmlspecialchars() translate only specialcharacter
For DEtails Refer These Links

No comments:
Post a Comment