note 81773 added to function.htmlentities

From: Date: Thu, 13 Mar 2008 03:32:15 +0000
Subject: note 81773 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-136996@lists.php.net to get a copy of this message
From SR: > There's no sane reason to use htmlentities() instead > of htmlspecialchars(). As long as you specify the charset > of a page with a Content-Type meta in the head of a > page (which you should ALWAYS do in the first place), > escaping all characters is completely pointless and will > only grow the size of your page. Only the special HTML > characters (<, >, &, etc.) need to be escaped, which is > exactly what htmlspecialchars() does This is inaccurate and unhelpful. There are many cases where you would want to convert a UTF-8 (or other) encoded string into appropriate HTML entity representations, as well as being just good practice to use more compatable entities instead of embedded character encodings. One such example is when using JavaScript for string manipulation, which doesn't support character sets and thus does not respect the UTF-8 BOM. By converting to full entities, JavaScript works with the entity text instead of byte codes. So long as the developer understands what is happening with encoding and how character sets work, they should make their own call on which function they need to use. ---- Server IP: 117.104.160.194 Probable Submitter: 152.91.9.115 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/81773 Del: integrated -- https://master.php.net/note/delete/81773/integrated Del: useless -- https://master.php.net/note/delete/81773/useless Del: bad code -- https://master.php.net/note/delete/81773/bad+code Del: spam -- https://master.php.net/note/delete/81773/spam Del: non-english -- https://master.php.net/note/delete/81773/non-english Del: in docs -- https://master.php.net/note/delete/81773/in+docs Del: other reasons-- https://master.php.net/note/delete/81773 Reject -- https://master.php.net/note/reject/81773 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136996) next »