Re: fopen
| From: | Kevin Stone | Date: | Wed, 05 Mar 2003 22:48:16 +0000 |
| Subject: | Re: fopen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138385@lists.php.net to get a copy of this message | ||
Please take another look at the manual page on fopen(). You're not using it
correctly. fopen() does not return the contents of the file, it retuns a
resource handel. You pass the handel as a parameter to fread() in order to
read the file.
http://www.php.net/manual/en/function.fread.php
If all you want is to get the contents of a file into a variable then you
can use something like this:
$contents = implode('', file("myfile.txt"));
- Kevin
----- Original Message -----
From: "John Taylor-Johnston" <taylorjo@collegesherbrooke.qc.ca>
To: <php-general@lists.php.net>
Cc: "John Taylor-Johnston" <jtjohnston@courrier.usherb.ca>
Sent: Wednesday, March 05, 2003 3:22 PM
Subject: [PHP] fopen
> #http://www.php.net/manual/en/function.fopen.php
>
> $contents = fopen ("/home/pathto/file.txt", "r");
>
> if ($contents){echo"<textarea>$contents</textarea>";}
> else{echo "no contents there";}
>
> Questions:
> What is the use of "@fopen"?
> Does anyone see a better way?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>