For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2004 > HTML To ASCII and Back









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HTML To ASCII and Back
Viruss

2004-05-28, 7:31 am

I am now creating a message board and when the user types in a message and
pushes enter the board will not add the <br> for me. What I want to know is
simply this. Is there a function that will take the raw text and add stuff
like <br> or will I have to write a set of functions that will do this. Any
help would be great thanks.


Alvaro G Vicario

2004-05-28, 7:31 am

*** Viruss wrote/escribió (Fri, 28 May 2004 10:26:52 GMT):

> I am now creating a message board and when the user types in a message and
> pushes enter the board will not add the <br> for me. What I want to know is
> simply this. Is there a function that will take the raw text and add stuff
> like <br> or will I have to write a set of functions that will do this. Any
> help would be great thanks.


Check:

nl2br()
htmlspecialchars()
htmlentities()

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Shane Lahey

2004-05-28, 11:32 am

On Fri, 28 May 2004 10:26:52 GMT, "Viruss" <viruss@shaw.ca> wrote:

>I am now creating a message board and when the user types in a message and
>pushes enter the board will not add the <br> for me. What I want to know is
>simply this. Is there a function that will take the raw text and add stuff
>like <br> or will I have to write a set of functions that will do this. Any
>help would be great thanks.
>

yes there is (kind of)

example:

<?php

$string = "my string is <this> & that\n";
$string = HTMLEntities( $string ); // change & to & etc....
$string = nl2br( $string ); // change newlines to <br />

echo $string . "\n";

?>


#### will produce ####

my string is &lt;this&gt; & that<br />

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com