html encoding

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
cauri
Forum Newbie
Posts: 4
Joined: Thu Feb 26, 2004 9:04 am

html encoding

Post by cauri »

new to php.
I have html code stored in a mysql database. When the query results come up, I would like the html to format naturally in the browser. How do I do this?

cauri
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Ehhh... just [php_man]echo[/php_man] it :D
User avatar
no_memories
Forum Contributor
Posts: 145
Joined: Sun Feb 01, 2004 7:12 pm
Location: New York City

Post by no_memories »

For xhtml:

<?php echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

For other html types follow the same rules as above but without the xml. Simply make your doc type so that PhP can recognize and process it.

Don't forget to make your document end with a .php instead of say .html
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

no_memories wrote: For other html types follow the same rules as above but without the xml. Simply make your doc type so that PhP can recognize and process it.
Doctype has nothing to do with PHP :o And even HTML has nothing to do with PHP ;) HTML is just a plain text from the PHP point of view.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Though in newbie logic echo()'ing or print()'ing HTML might seem that it wll display
<font color="red">Text</font>
instead of
Text (red text)
but it does not. It will be parsed by the browser as normal. :)
Post Reply