473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 4431
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I'm using Apache/1.3.28 (SuSE 7.1, kernal 2.4) with PHP/4.3.2. I have the following code to help cleanse form data. function cleanData($sourceData, &$cleanData) { foreach($myData as...
6
by: John Dunlop | last post by:
(Crossposted and followups set. Hope you don't mind Markus.) The Manual expresses the parameters of htmlentities as: string string ] http://www.php.net/manual/en/function.htmlentities.php ...
2
by: tco | last post by:
Hi all, I'm searching a reverse function for htmlentities.... i couldn't find anything in the manual and over forums :-/ does anyone have an idea ? many thanks in advance, -- tco
0
by: Gandalf | last post by:
Hi all! I'm writting a web application using IIS and Python. I would like to have the Python equvalient of the PHP functions 'htmlentities' and 'htmlspecialchars'. E.g. to convert a' >>>> ...
7
by: Taras_96 | last post by:
Hi all, I was hoping to get some clarification on a couple of questions I have: 1) When should htmlspecial characters be used? As a general rule should it be used for text that may contain...
0
by: netvision | last post by:
Hai Everyone Iam usign Backbase AJAX with PHP. Iam having problem with including the htmlentities fucntion within the xmp tag. Actually the conversion is not working.But thats works fine if the...
2
by: matthud | last post by:
<?php //MAKE IT SAFE $chunk = $_POST; $title = $_POST; $url = $_POST; $tags = $_POST; $user = $_POST; $safe_chunk = mysql_real_escape_string(htmlentities($chunk)); $safe_title =...
9
nathj
by: nathj | last post by:
Hi, As you can tell by the subject of this post I'm having a spot of bother with htmlentities() and html_entity_decode(). I have built/am building a web site that allows user feedback. When...
8
by: mijn naam | last post by:
Can someone please explain to me why/when one would use htmlspecialchars instead of htmlentities? I know: if you only want to get certain characters translated. This is not the answer I'm...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.