Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
The manual says that the default parameter is:

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

Why is that the default and not:

ENT_QUOTES - Will convert both double and single quotes.

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

Re: htmlentities()

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

Rik Wasmus

Re: htmlentities()

Rik Wasmus wrote:

Quoted text here. Click to load it

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

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

                               Bottled Water

Site Timeline