php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41094 filesystem functions not write to files after die()
Submitted: 2007-04-15 15:49 UTC Modified: 2007-04-16 00:48 UTC
From: speakus at mail dot ru Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.1 OS: winXPsp2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: speakus at mail dot ru
New email:
PHP Version: OS:

 

 [2007-04-15 15:49 UTC] speakus at mail dot ru
Description:
------------
I reproduce problem only if PHP Installed as an Apache module!
No issue on php-cgi


Reproduce code:
---------------
<?php
function Shutdown()
{
  file_put_contents("debug.txt", "text", FILE_APPEND);
}
register_shutdown_function('Shutdown');


Expected result:
----------------
file "debug.txt" updated/created with text

Actual result:
--------------
no file created or no updated file

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-15 17:44 UTC] johannes@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Apache changes the working directory to / so you\'re actually writing to /debug.txt.
 [2007-04-15 23:22 UTC] speakus at mail dot ru
code:
<?php
file_put_contents("debug.txt", "text", FILE_APPEND);
?>
work - absolutely correcly - create/update the file
but submited code - is not.
I think it is not possible in simple case "other working directory" ;)
 [2007-04-16 00:48 UTC] scottmac@php.net
When the shutdown function is called the working directory changes to what it was prior to the script running, in this case Apache uses /

If you use an absolute path then it will append correctly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC