Using PHP to output a text version of a page

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
octavian_3009
Forum Newbie
Posts: 9
Joined: Tue Feb 24, 2009 6:28 pm

Using PHP to output a text version of a page

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

But you're serving the exact same content?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

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

Post 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.
octavian_3009
Forum Newbie
Posts: 9
Joined: Tue Feb 24, 2009 6:28 pm

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

Post by octavian_3009 »

Thank you for the mention of strip_tags(). I had completely forgotten about that.
Post Reply