note 51253 added to function.fwrite
| From: | Will at EnigmaChannel dot com | Date: | Thu, 24 Mar 2005 17:06:47 +0000 |
| Subject: | note 51253 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86895@lists.php.net to get a copy of this message | ||
(Very important information that would have saved me hours of stress...)
The file you want to write to should be in the same folder as the php page that has your script:-
Using fopen('tester.txt', 'w',1); to write to the file 'tester.txt' in
your include folder, doesn't appear to work on my Mac OS X Server.
Also using fopen('tester.txt', 'a',1); does not create the file, it returns an
error.
You must set the file permissions for the file you wish to write to. Create the file first then on
the Mac you right-click or Apple-click the file (tester.txt) and do Get Info. Then set the
Permissions to Read+Write.
This code will then work:-
$file = fopen('tester.txt', 'w');
fwrite($file, 'string to write');
fclose($file);
----
Manual Page -- http://www.php.net/manual/en/function.fwrite.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51253
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51253&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51253&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51253&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51253&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51253&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51253&report=yes
Search -- http://master.php.net/manage/user-notes.php