phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Web Content: Displaying Content of File

Tag: file, text   Category: PHP Basic
post: 25 Apr 2008 read: 72


Web Content Tips - Part 1: If you want to display contents of a text file on web page, you can use this trick. First, put content type text/plain at header. Then, read file use readfile() PHP function. This is simple sample:

<?php
$file = "test.php";

header("Content-Type: text/plain");

readfile($file);
?>

The readfile() function reads a file. it will write its content to the output buffer. In this case, we tell to browser that we want to display as plain text. This force the client to preserve line breaks and carriage returns when rendering the file's contents.




| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting