[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] PHP & MySQL



On Saturday 09 March 2002 10:34 am, Matt Fairtlough mumbled:
>  I thought that the \n in the format string meant a carriage return.  In
> my further ignorance I assumed that it would then be translated to a
> <br>.  But perhaps it does insert a cr as you suggest below for the echo
> "stuff\n", and just produce a cr in the "source".  Hmm.  I wonder if
> there is a formal semantics anywhere for php.  Then I might stand a
> chance of understanding just how it works :-)

In essence, all you are producing is ASCII output. If it did ASCII - HTML 
conversion on the fly, you would be limited to only ever producing HTML. I 
produce XML, GIF, JPEG, and numerous other formats using PHP, so that 
wouldn't do at all.

There is in fact a way to convert raw ASCII formatted text to HTML. You can 
use the nl2br and htmlspecialchars functions.

echo nl2br(htmlspecialchars("This is my string\nIt has formatting characters, 
and \"QUOTES\" and things.");

would produce:

This is my string<br>
It has formatting characters, and &quot;QUOTES&quot; and things.

This goes some way to helping your situation, although it is generally faster 
just to type the <br>

HTH

Craig
___________________________________________________________________

Sheffield Linux User's Group - http://www.sheflug.co.uk . 
To unsubscribe from this list send mail to 
shef-lug-request@list.sheflug.org.uk with the word
"unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.