Page 1 of 1

method to output html code

Posted: Tue Feb 02, 2010 9:19 pm
by wanger220
Hi all,

Looking for suggestions on how to output and display html code. I want to write a script to call variables from a mysql db and then output html code that can be pasted into, say, craigslist.

I initially thought to approach this like producing an xml document, by echoing a series of strings and using

Code: Select all

<pre>
or

Code: Select all

<code>
. However I'm wondering if there are better ways to do this, like using ob or something else. I've just never encountered this before.

I searched the forums a few times but didn't come up with any similar threads. Any help?

Re: method to output html code

Posted: Tue Feb 02, 2010 10:35 pm
by iamngk
you can use htmlentities() to print html code

Code: Select all

 
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
 
Above output will display the html coding in browser. you can try this.

Re: method to output html code

Posted: Wed Feb 03, 2010 8:01 am
by wanger220
Awesome. Thank you for the help. I searched for an hour but couldn't find an appropriate method - though I figured there would be something simple out there.