Log in

View Full Version : html tags in output



gurmeet
10-11-2010, 08:07 AM
i am using a nl2br tag...


nl2br($text)


but in text there are somr <img> tags... in output nl2br method convert <img> to special chars...
instead of showing me pictur for img tag it just displays a <img> tag with full source.....

what to do..?

traq
10-11-2010, 01:13 PM
nl2br() doesn't do that... are you sure you don't have something like htmlentities() running at another point in your script?

bluewalrus
10-11-2010, 03:06 PM
If you view the souce does it say &lt;img ... &gt;?

We'd need to see your code for a more detailed answer.

Actually if you have "new lines"(\n or\r) in your source code i guess this code occur as well because it would write it as

<img <br /> src="" />

but that would display on more than 1 line. So seeing the actual source of the output could help as well as the code.

gurmeet
10-12-2010, 04:54 AM
no i never used the function line htmlentities

yes my out put code is lying here...

&lt;img src='img/smilies/icon_e_biggrin.gif'&gt; <br />
&lt;img src='img/smilies/icon_eek.gif'&gt; <br />
&lt;img src='img/smilies/icon_razz.gif'&gt; <br />
&lt;img src='img/smilies/icon_e_surprised.gif'&gt;ops: <br />
&lt;img src='img/smilies/icon_e_confused.gif'&gt;: <br />
&lt;img src='img/smilies/icon_cry.gif'&gt; <br />



i only used the nl2br function

traq
10-12-2010, 05:45 AM
I have no idea. I've tested

<?php

$tag = '<img src="test.jpg">'."\n";
echo nl2br($tag);

?>locally and on two different live servers, each time I got

<img src="test.jpg"><br />

gurmeet
10-12-2010, 07:03 AM
ok.. leave it what nl2br does....



is ther any method to convert such symbols to proper <img > tag?

bluewalrus
10-12-2010, 01:21 PM
htmlspecialchars_decode();

I'd try and find what it is being converted though.

traq
10-12-2010, 02:23 PM
absolutely, otherwise, you might not catch it at the right spot; or it could happen again somewhere