Page 1 of 1

Using PHP to output a text version of a page

Posted: Mon Sep 28, 2009 7:50 pm
by octavian_3009
I would like give the visitors of my site the ability to view my pages in a plain text format (for accessibility reasons). I am aware that sending a page with a mime type of text/plain will result in a such a page. I was hoping to have PHP look for a string in the page URL and send different mime types when seeing different strings.
For example, if the URL was http://www.example.com/index.php?output=text, then it would send the page using the text/plain mime type. However, if the URL was http://www.example.com/index.php?output=html, the mime type would be text/html.
What would be an example of some PHP code which could be used perform this task?

Re: Using PHP to output a text version of a page

Posted: Mon Sep 28, 2009 8:50 pm
by requinix
But you're serving the exact same content?

Re: Using PHP to output a text version of a page

Posted: Tue Sep 29, 2009 5:46 am
by jackpf
Use $_GET and header().

You might want to use OB and strip_tags() as well unless you want users to see all the HTML tags.

Re: Using PHP to output a text version of a page

Posted: Wed Sep 30, 2009 8:51 pm
by octavian_3009
Thank you for the mention of strip_tags(). I had completely forgotten about that.