By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

htmlentities is not working for me

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
*** 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.