PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > htmlentities()
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
htmlentities()

Réponse
 
LinkBack Outils de la discussion
Vieux 28/02/2008, 14h51   #1
Jerry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut htmlentities()

The manual says that the default parameter is:

ENT_COMPAT - Will convert double-quotes and leave single-quotes
alone.

Why is that the default and not:

ENT_QUOTES - Will convert both double and single quotes.


Also, what does 'ENT' refer to here? Thanks.
  Réponse avec citation
Vieux 28/02/2008, 14h59   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: htmlentities()

On Thu, 28 Feb 2008 15:51:23 +0100, Jerry <Jerry@nospam.not> wrote:

> The manual says that the default parameter is:
>
> ENT_COMPAT - Will convert double-quotes and leave single-quotes alone.
>
> Why is that the default and not:
>
> ENT_QUOTES - Will convert both double and single quotes.


Because by default, most people use double quotes for their tag attributes
rather then single quotes (which are just as valid offcourse). In most
circumstances, you don't want both (for instance, setting an onclick
attribute on a tag in double quotes: you want the double quotes as
entities, converting the single quotes will usually end up destroying the
javascript in there.

> Also, what does 'ENT' refer to here? Thanks.


ENTities
--
Rik Wasmus
  Réponse avec citation
Vieux 28/02/2008, 15h28   #3
Toby A Inkster
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: htmlentities()

Rik Wasmus wrote:

> (for instance, setting an onclick attribute on a tag in double quotes:
> you want the double quotes as entities, converting the single quotes
> will usually end up destroying the javascript in there.


No it won't.

<p onclick="window.alert(&#x27;Hello&#x27;">Say hello</p>
<p onclick="window.alert('Hello');">Say hello</p>

should both act exactly the same.

The Javascript interpreter never sees the "&#x27;" -- it is converted to a
single quote mark by the HTML parser before passing it on to the scripting
engine.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 29 days, 21:42.]

Bottled Water
http://tobyinkster.co.uk/blog/2008/02/18/bottled-water/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h11.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10111 seconds with 11 queries