Forum Moderators: coopster

Message Too Old, No Replies

echo unactive html

         

ineedmoney

3:54 pm on May 22, 2006 (gmt 0)

10+ Year Member



I have a script that will echo html that my visitors will be able to copy and paste, I wanted to add a link to my site in the output, but what I have done just creates an active link, how can I make it so the HTML is echo as only text?

this is my code:

$a = '<font size="2"><a title="example" href="http://www.example.com">example</a><font>';

[edited by: jatar_k at 3:55 pm (utc) on May 22, 2006]

nfs2

4:01 pm on May 22, 2006 (gmt 0)

10+ Year Member



Try replacing < with &lt; and > with &gt;

jatar_k

4:01 pm on May 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I usually see html needing to be copied echo'ed into a textarea

Receptional Andy

4:02 pm on May 22, 2006 (gmt 0)



You need to use htmlentities in your output so that the less than and greater than symbols are not treated as code, e.g:

$a = htmlentities('<font size="2"><a title="example" href="http://www.example.com">example</a><font>');
echo $a;

ineedmoney

4:05 pm on May 22, 2006 (gmt 0)

10+ Year Member



Thankyou nfs2

Unfortanutely that did not work for me, The HTML still came out as a link

Any other suggestions?

ineedmoney

4:11 pm on May 22, 2006 (gmt 0)

10+ Year Member



Thank you Receptional Andy

That did the trick. I must have been searching for that code for about 2 hours.