Re: passthru
| From: | Colin Guthrie | Date: | Mon, 06 Aug 2007 09:38:45 +0000 |
| Subject: | Re: passthru | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260230@lists.php.net to get a copy of this message | ||
Richard Heyes wrote:
>> Does anyone know way to passthru man pages so they don't show the
>> ascii formating?
>
> You could:
>
> 1) Replace all newlines (ASCII 10) with a <br> tag. htmlspecialchars()
> will do this for you.
Does it? I thought it only replaced entities. \n is not a "special char"
in html lingo in that you can include them happily in a document and it
is still syntactically correct!
I believe you want the nl2br() function instead here.
> 2) Use a <pre> tag within which newlines are preserved
> 3) Use preg_replace to replace non-printable characters (Can't remember
> how exactly, but everything you need is in the manual - you will want
> to strip everything from ASCII 1 - ASCII 32. IIRC.
>
I think it would be more to do with the special characters for making
things bold and overwriting etc. rather than new lines specifically but
I think you're 3rd point should work (without thinking about it too much :))
Col