View Full Version : Open and print contents of a file?

03-30-2003, 11:23 PM
This may be utterly moronic, I was messing about and thought I'd be able to open and print the contents of a file using the followng:

$content = fopen ("path/url", "r");
print "$content";
?>Actually the result is Resource ID#1. So obviously not, why?


03-30-2003, 11:37 PM

// conect to handle a file
$file_handler = fopen("http://www.php.net/", "r");

/* to open a local file use this instead
$file_handler = fopen("data.txt", "r");

// read the contents
$contents = fread($file_handler, filesize($file));

// close the file

// print the contents on your page
echo $contents;

03-31-2003, 12:07 AM
YAY! :eek::)
$filename = "path";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
print "$contents";

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum