468,769 Members | 2,274 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

htmlentities is not working for me

jl
>From the php manual I copied and pasted this example:

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

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>

However, when I run it in my browser, the output is wrong:

A 'quote' is <b>bold</b>A 'quote' is <b>bold</b>

the < is not converted to &lt (no conversion is taking place)

Is there a configuration that would disable htmlentities?
Does anyone have any idea as to what would cause htmlentities to not
work?

Thanks!
jl

Aug 26 '06 #1
3 4166
jl

jl wrote:
From the php manual I copied and pasted this example:

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

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
?>

However, when I run it in my browser, the output is wrong:

A 'quote' is <b>bold</b>A 'quote' is <b>bold</b>

the < is not converted to &lt (no conversion is taking place)

Is there a configuration that would disable htmlentities?
Does anyone have any idea as to what would cause htmlentities to not
work?

Thanks!
jl
I figured it out. The browser was reconverting the string.

Aug 26 '06 #2
Rik
jl wrote:
jl wrote:
>>From the php manual I copied and pasted this example:

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

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);

// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
>>>

However, when I run it in my browser, the output is wrong:

A 'quote' is <b>bold</b>A 'quote' is <b>bold</b>

the < is not converted to &lt (no conversion is taking place)

Is there a configuration that would disable htmlentities?
Does anyone have any idea as to what would cause htmlentities to not
work?

Thanks!
jl

I figured it out. The browser was reconverting the string.
Not exactly. The browser was interpreting it as the aplicable characters
instead of HTML tags, which is what it is used for.

If you want to display &lt;, you'll have to have &amp;lt; in yout code.

--
Rik Wasmus
Aug 26 '06 #3
*** jl escribió/wrote (26 Aug 2006 07:19:53 -0700):
I figured it out. The browser was reconverting the string.
The browser is not actually altering the string. You need to use the
"View-Source code" menu.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randell D. | last post: by
2 posts views Thread by tco | last post: by
reply views Thread by Gandalf | last post: by
7 posts views Thread by Taras_96 | last post: by
2 posts views Thread by matthud | last post: by
8 posts views Thread by mijn naam | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.