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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 - 11 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 10:01:28 2024 UTC