Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



Professional PHP4 Web Development Solutions    (ISBN: 1861007434)


 

 List Price: $49.99
 Our Price: $34.99
 Used Price: $34.94

 Release Date: November, 2002
 Manufacturer: Wrox Press Inc (Paperback)
 Sales Rank: 17,061

 Author: Luis Argerich, Alison Gianotto, Raj Dash, Matt Anton, Jon Stephens, Bryan Waters, Jo Henrick









More Info

 Read File 2003-02-17 00:20:09
  php 
Category: source:php:files
Description: Read in text from a file.
Platform: all
Author: detour
Viewed: 3964
Rating: 3.8/5 (23 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
readfile.php
<?php
  // readfile.php by detour@metalshell.com
  //
  // Read in text from a file.
  //
  // http://www.metalshell.com/
  //

  $yourfile = '/tmp/file';

  // Open the file for reading.
  $fd = fopen($yourfile, "r");
  
  // Read in all of the data in one big hunk
  $data = fread($fd, filesize($yourfile));

  // Close the file.
  fclose($fd);

  // Convert all return char's to <br> for html
  $data = ereg_replace("\n", "<br>", $data);

  // Print it all out.
  echo $data;

?>
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?