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

Simple question for once ?

P: n/a

How do I get a text string that may contain HTML tags to
echo out to a web browser verbatim?

IE I want the tags to be printed out - not interpreted.

Thanks
May 11 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 11 May, 17:38, harvey <harvey....@blueyonzders.comwrote:
How do I get a text string that may contain HTML tags to
echo out to a web browser verbatim?

IE I want the tags to be printed out - not interpreted.

Thanks
$string = '<h1>likethis</h1>';

echo htmlentities( $string );
//or
echo highlight_string( '<?php' . $string . '?>' );
//where adding <?php is a trick to highlight non-php, if you dont
mind the php tags appearing.(u could kill them afterwards)

May 11 '07 #2

P: n/a
In article <11**********************@o5g2000hsb.googlegroups. com>,
ma********@gmail.com says...
On 11 May, 17:38, harvey <harvey....@blueyonzders.comwrote:
How do I get a text string that may contain HTML tags to
echo out to a web browser verbatim?

IE I want the tags to be printed out - not interpreted.

Thanks
$string = '<h1>likethis</h1>';

echo htmlentities( $string );
//or
echo highlight_string( '<?php' . $string . '?>' );
//where adding <?php is a trick to highlight non-php, if you dont
mind the php tags appearing.(u could kill them afterwards)

That was fast -
I am a bit red faced as I actually recognise that command but thought it
did something else !

Your second method is a new one to me - I will experiment with that.

thank you !
May 11 '07 #3

P: n/a
On 11 May, 17:51, harvey <harvey....@blueyonzders.comwrote:
In article <1178901903.347883.242...@o5g2000hsb.googlegroups. com>,
matt.fa...@gmail.com says...
On 11 May, 17:38, harvey <harvey....@blueyonzders.comwrote:
How do I get a text string that may contain HTML tags to
echo out to a web browser verbatim?
IE I want the tags to be printed out - not interpreted.
Thanks
$string = '<h1>likethis</h1>';
echo htmlentities( $string );
//or
echo highlight_string( '<?php' . $string . '?>' );
//where adding <?php is a trick to highlight non-php, if you dont
mind the php tags appearing.(u could kill them afterwards)

That was fast -
I am a bit red faced as I actually recognise that command but thought it
did something else !

Your second method is a new one to me - I will experiment with that.

thank you !
well i was too quick for my puny brain
it should be

highlight_string( '<?php ' . $string . ' ?>' );

of course!!

May 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.