Re: fopen
| From: | John Taylor-Johnston | Date: | Wed, 05 Mar 2003 23:15:12 +0000 |
| Subject: | Re: fopen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138389@lists.php.net to get a copy of this message | ||
Mat>To get data out of the file that you
Mat>have opened, you will need to read() it n.
Mat>http://www.php.net/manual/en/function.fread.php
Ok, how about this? What about error checking if the file contains something as I include below? Is
that enough?
<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
if ($contents){echo"<textarea>$contents</textarea>";}
else{echo "no contents there";}
?>