You are here: Re: htmlentities is not working for me -- never mind « PHP Programming Language « IT news, forums, messages
Re: htmlentities is not working for me -- never mind

Posted by Rik on 11/03/22 11:57

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 &#039;quote&#039; 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация