note 58656 added to function.fopen
| From: | Mario at tweakBSD dot org | Date: | Thu, 10 Nov 2005 20:57:06 +0000 |
| Subject: | note 58656 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98406@lists.php.net to get a copy of this message | ||
Just to mention today I read in a book I won't say here,
it is absolutly essential to call is_readable or is_writeable first when fopen'ing files to
pre-react on errors.
I think this approach is quite good but its not safe in my mind to say that a file is_readable or
is_writable even when they return true, there can be a short period between the calls where
something can happen so I think it is better to do it this way
<?PHP
$path = "./bla.txt";
if( ($fp = fopen($path, "mode") != false) {
// further file operations
}
?>
to be on the safe side. Or can someone tell me that is_readable or is_writable guarantees that fopen
with appropriate mode will return true??
----
Manual Page -- http://www.php.net/manual/en/function.fopen.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58656
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58656&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58656&report=yes
Search -- http://master.php.net/manage/user-notes.php