Re: fopen() and flock()
| From: | nicos@php.net | Date: | Mon, 02 Sep 2002 10:56:31 +0000 |
| Subject: | Re: fopen() and flock() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114900@lists.php.net to get a copy of this message | ||
Hi,
You should use a while(!feof) syntax so that can verify that the file is
not empty.
You should also use
$text = implode("",@file($filename));
Thats the easiest way to read a file. It will put each lines into an
array and you will just implode it into a variable
--
Merci de nous avoir choisi. - Thanks you for your choice.
Nicos - CHAILLAN Nicolas
nicos@worldakt.com
nicos@php.net
www.GroupAKT.com - Hébergement Group.
www.WorldAKT.com - Hébergement de sites Internet
"David McInnis" <david@dataovation.com> a écrit dans le message de news:
021001c25210$21c38010$6400a8c0@bigdaddy...
> I use fopen() in a template system that I have developed. I noticed
> that occasionally I get blank pages served up. Here is one of my
> snippets.
>
> $filename = "$ROOTDIR/content/myfile.txt";
> $fd = fopen ($filename, "r");
> $PAGE_CONTENT = fread ($fd, filesize ($filename));
> fclose ($fd);
>
> Doing this I get the contents of the file read into the $PAGE_CONTENT
> variable.
>
> I never use fopen() to write to files. Only read with the "r"
> directive. So what could be causing my conflicts? Do I need to flock
> the file to shared?
>
> I am running Linux PHP, Apache and Linux.
>
> David McInnis
>