method to output html code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wanger220
Forum Newbie
Posts: 19
Joined: Tue Feb 02, 2010 8:44 pm

method to output html code

Post 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?
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: method to output html code

Post 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.
wanger220
Forum Newbie
Posts: 19
Joined: Tue Feb 02, 2010 8:44 pm

Re: method to output html code

Post 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.
Post Reply