PHP Htmlentities Vs Htmlspecialchars Differences Php Functions
php htmlentities vs htmlspecialchars differences php functions
php, htmlentities, vs, htmlspecialchars, differences, php, functions
PHP Htmlentities Vs Htmlspecialchars Differences Php Functions
Post Description: php htmlentities vs htmlspecialchars differences php functions
POST# 462
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: PHP Htmlentities Vs Htmlspecialchars Differences Php Functions
so what is the difference between htmlspecialchars() and htmlentities?


htmlspecialchars � Convert special characters to HTML entities


htmlentities � Convert all applicable characters to HTML entities



htmlentities

PHP CODE:
<?php
$str = "A 'quote' is <b>bold</b>";

echo htmlentities($str);
echo htmlentities($str, ENT_QUOTES);
?>

OUTPUT
A 'quote' is &lt;b&gt;bold&lt;/b&gt;

A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;


htmlspecialchars

PHP CODE:
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; //
?>

OUTPUT
&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;




No Repies
(0) Comments for PHP Htmlentities Vs Htmlspecialchars Differences Php Functions

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload