Re: How to know information about a file pointer ?

From: Date: Sat, 28 Oct 2000 00:16:08 +0000
Subject: Re: How to know information about a file pointer ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22399@lists.php.net to get a copy of this message
At 03:58 PM 10/27/00 , Tan Minh TRUONG wrote:
Hello, I want to be able to know the characteristics of a file pointer : $fp=fopen("file.dat","w"); I want to be able to get the "w", so that I can compare it to w, a, r, w+ and so on. I am working on a minimal subset for PHP basic uses.
Ummm, I'm not quite sure what you mean here. Couldn't you do something like:
        if ($IWantToWrite) {
                $Mode = 'w';
        } elseif ($IWantToRead) {
                $Mode = 'r';
        } # ...and so on
        $fp = fopen('file.dat', $Mode);
If you want to know if your filesystem will allow you to read or write a file, then use is_readable() or is_writeable(); see
        http://www.php.net/manual/function.is-writeable.php
and
        http://www.php.net/manual/function.is-readable.php
-steve +------------------------------------------------------------------------+
| Steve Edberg                           University of California, Davis |
| sbedberg@ucdavis.edu                                     (530)754-9127 |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

« previous php.general (#22399) next »