note 52576 deleted from function.fopen by tularis
| From: | tularis@php.net | Date: | Mon, 26 Dec 2005 14:14:41 +0000 |
| Subject: | note 52576 deleted from function.fopen by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100728@lists.php.net to get a copy of this message | ||
Note Submitter:
----
'fopen' only opens a handle to the file. You may want to use it in this format;
<?php
$hi = fopen("myfile.txt","r");
$text = fread($hi,filesize("myfile.txt"));
fclose($hi);
?>
So '$text' would = contents of file, or use this alternative function;
<?php
$hi = file("myfile.txt");
print_r($hi);
?>
'file' reads the contents of your file, and will store it in the '$hi' variable
as an array of lines. 'print_r' will simply print this array in an easy-to-read way.