php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52141 little problem
Submitted: 2010-06-22 12:05 UTC Modified: 2010-06-27 22:00 UTC
From: haheute at googlemail dot com Assigned: wiesemann (profile)
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: haheute at googlemail dot com
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-27 22:00 UTC] wiesemann@php.net
-Status: Open +Status: Bogus -Package: Website problem +Package: Documentation problem -Assigned To: +Assigned To: wiesemann
 [2010-06-27 22:00 UTC] wiesemann@php.net
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).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 02:01:36 2025 UTC