PHP htmlspecialchars()


Back to php.


thibault    (2009-04-09)

thibault

PHP htmlspecialchars()

string htmlspecialchars (string $string [, int $quote_style [, string $charset  [, bool $double_encode]]])


Many HTML character entities must be written in a certain way. This function converts some of these characters. To translate every HTML character entities you may use the htmlentities() function.

This function is particularly useful to avoid that users can post HTML markup in a forum, in this case one it is recommended to use a BBcode-like function that can allow users to type in example [i] instead of <i>.

By using the htmlspecialchars() function

    '&' (ampersand) will become '&amp;'
    '"' (double quote) will become '&quot;' if ENT_NOQUOTES is not set.
    ''' (single quote) will become '&#039;' if ENT_QUOTES is set.
    '<' will become '&lt;'
    '>' will become '&gt;'

The quote_style argument (optional) tells the function what to do with the single and double quote characters. By default the mode is ENT_COMPAT, it only translates the double-quote character, the single-quote remains untranslated. If ENT_QUOTES is set, both single and double quotes are translated, if ENT_NOQUOTES is set neither single nor double quotes are translated.

The charset argument (optional) defines the character set used in conversion. By default the character set is ISO-8859-1 but you may also use these character sets, supported in PHP 4.3.0 and later.

ISO-8859-1  ISO8859-1  Western European, Latin-1
ISO-8859-15 ISO8859-15 Western European, Latin-9.
UTF-8   ASCII compatible multi-byte 8-bit Unicode.
cp866 ibm866, 866 DOS-specific Cyrillic charset.
cp1251 Windows-1251, win-1251, 1251 Windows-specific Cyrillic charset.
cp1252 Windows-1252, 1252 Windows specific charset Western European
KOI8-R koi8-ru, koi8r Russian.
BIG5 950 Traditional Chinese (Taiwan).
GB2312 936 Simplified Chinese (National character set).
BIG5-HKSCS   Big5 with Hong Kong extensions, Traditional Chinese.
Shift_JIS SJIS, 932 Japanese
EUC-JP EUCJP Japanese



(more options below)

dario    (2010-04-05 16:28:23)
PHP htmlspecialchars()

Nice article on my opinion. But I think that myphpform.com can gathered information from php tutorials.


*temule    (2010-06-17 15:42:42)
14 years ago

<img src = "image / img1.jpeg">


See also


ficgs
More websites

You must register to see these links, as this is a collaborative page, then you may change the order of the links by clicking the icons before the titles.



admin
Other websites

The following links might be less relevant, please change their ranks if you find them useful.


 htmlspecialcharacters help! - PHPBuilder.com
phpbuilder > board/showthread.
  1. PHP Builder: manuals, content management systems, scripts, classes
 Javascript equivalent for PHP's htmlspecialchars
kevin.vanzonneveld > techblog/article/javascript equivalent for

 htmlspecialchars - HTML in PHP - Htmlspecialchars PHP
php.about > od

 HTML encode string conversion (PHP htmlspecialchars)
voormedia > en/tools/html encode string conversion htmlspecialchars.

If you are a designer and in need of help by one of the programmers...

 php - htmlspecialchars « php help
phphelper.wordpress

 b2evolution :: View topic - [FIXED] Bug in _misc.funcs.php - *
forums.b2evolution > viewtopic.

 Rails for PHP Developers - Reference for PHP htmlspecialchars in Ruby
railsforphp > reference/strings/htmlspecialchars

Are you a PHP developer interested in the Ruby on Rails...
Looking for Rails or PHP web application development,...

 Nabble - Horde - Bugs - [Tickets #7305] broken php htmlspecialchars workaround needed
nabble > Tickets 7305 broken

 what is the equivalent in javacript of PHP's htmlspecialchars($str) / htmlspecialchar - Dynamic Drive Forums
dynamicdrive > forums/showthread.

  * problem
experts exchange > Web Development/Web Languages Standards

  * 函数 - 用法|在线手册|属性|方法
fzs8

 PHP :: Htmlspecialchars Like Magic_quotes?
bigresource

 PHP: htmlspecialchars - Manual
algorytmy > doc

zaznacz działy do przeszukania (brak wyboru = wszystkie...
O wysokich kompetencjach zawodowych Darka nie ma co...

 [Tickets #7305] broken php htmlspecialchars workaround needed
lists.horde > archives/bugs/Week of Mon 20080908/038936

...| broken php htmlspecialchars workaround needed Queue...
[Tickets #7281] Re: First Email from vCard ends up in email by...
...ote: php htmlspecialchars function is stupid: When presented with...

 PHP: htmlspecialchars - Manual
jp.php > htmlspecialchars

To reverse the action of htmlspecialchars(), use this code:...
used this function for making a variable javascript compatible...
Here's something that replicates the appearance of...

 PHP: htmlspecialchars - Manual
fr.php > htmlspecialchars

To reverse the action of htmlspecialchars(), use this code:...
used this function for making a variable javascript compatible...

 PHP, * , charset iso-8859-2 not supported
freebsd > listserv/archive/users l/2006q2/016478

PHP, htmlspecialchars(), charset iso-8859-2 not...
Zkusil bych zminovany UTF-8 zpusob, jinak to zrejme...

 PHP : htmlspecialchars - Convert special characters to HTML entities
thaicreate

Certain characters have special significance in HTML, and should...
Any other character sets are not recognized and ISO-8859-1 will...

  * Function
kenhmuaban > manual

 PHP "htmlentities()" and " * " Buffer Overflows - Secunia Advisories - Vulnerability Information - Secunia.com
secunia > advisories/22653

Fujitsu Interstage Products IP Address Restriction Bypass Security...
Joomla! Mosets Tree Component Cross-Site Request Forgery...
Please provide information about patches, mitigating factors,...

 Htmlspecialchars to display html tags on page
plus2net

Now to display the code for the above line formatted in different...
Separating domain and userid part from an email address using...
Random string generator with number and alphabets for...

 Id: edit.php,v 1.8 2009/03/31 20:28:54 agrabs dead $ /** * prints the form to edit the feedback items such moving, deleting and so on * * @version $Id...
cvs.moodle > contrib/plugins/mod/feedback/edit.

 help writing htmlspecialchars code correctly - ProgrammingTalk
programmingtalk > showthread.

 [Tickets #7305] broken php htmlspecialchars workaround needed
archives.free.net > message/20080908.145636.b4faf69c.it

 CS 85 PHP Programming - Strings
home.earthlink > ~kengeddes/cs85/lectureNotes/strings

if one operand is a number, other operand is cast to a...
two types of URL encoding - spaces handled differently...

 RE: [PHP] * - ObjectMix Forum
objectmix

 Validating PHP forms
myphpform > validating forms.

and simply call this function whenever we need to...
function, strips any quotes escaped with slashes and...

 goldvision.net - PHP / htmlspecialchars
goldvision > us/en/manuals

 PHPXRef 0.7 : Mambo 4.6.5 : /administrator/modules/mod_components.php source
mambo developer > api/administrator/modules/mod components.

/** ensure this file is being included by a parent file...
FUNC_DATA={ 'loadobjectlist': ['loadobjectlist', 'Load a list of...



Response  
 

Guest name   (option)     Register
Please sum : 3181 + two  




Trackbacks : If you talked about this article in your blog or website, you may instantly get a backlink 
There's no trackback at the moment.