|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-22 12:05 UTC] haheute at googlemail dot com
Description:
------------
Beispiel #1 Ein einfaches Beispiel für fwrite:
does not work, because is_writeable is before fopen
i had to change to:
1. fopen and than:
2. is_writeable and
3. fwrite
otherwise an error occurs, saying file xy is not writeable
greetings.h.
Test script:
---------------
this works on my webspace (already changed from the php.net.example)
//--bildtexte-einschreiben
$filename = "upload_anonym/" . $name.".txt";
if (!$handle = fopen($filename, "w")){
print "Kann die Datei $filename nicht öffnen";
exit;
}
if (is_writable($filename)) {
if (!fwrite($handle, $bildtext)) {
print "Kann in die Datei $filename nicht schreiben";
exit;
}
print "<span style=\"background-color:#ad8; font-size:0.9em;\">Bildtexte gespeichert in: ".$filename."</span>";
fclose($handle);
}else{
print "Die Datei $filename ist nicht beschreibbar.";
}
//--------------------------
Expected result:
----------------
text file containing a picture description
Actual result:
--------------
kk
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
The example shows how to append ('a' mode in fopen() call) something to a file. This requires that the file exists and that the file is writable. I.e. the example assumes that test.txt has already been created (=> this is outside of the scope of the example).