|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-13 20:23 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 09:00:01 2025 UTC |
Description: ------------ I have a member function which is been called in the destructor of this object. The called function has to write a string into a file, which shall be stored in a subdirectory. In my case its F:\php\logs (php is the dir where the script is stored, in the \logs dir shall the created file be stored). The first problem I recognized was that PHP can't read the current directory in the function, the second one is that it creates files in a totally different directory. If I tell this function "mkdir("./logs/");", it won't create a subdir called "logs" in F:\php, but in D:\ (-> D:\logs)! If I write the absolute directory, the thing works, but it's useless on a webspace. My php.ini hasn't set anything to D:\ just PHP is installed in D:\php\ Reproduce code: --------------- class someclass { // Constructors, functions, vars... public function someclass_make_file($mode) { if(defined('DEBUG_LOG')) { switch($mode) { case 3: $dl = $this->debug_log; // "Info" $dfl = fopen("logs/".time().".txt", "a"); fwrite($dfl, $dl); fclose($dfl); break; } } return true; } public funtion __construct() { $this->someclass_make_file(3) } } Expected result: ---------------- A file F:\php\logs\1134123412.txt Actual result: -------------- A file D:\logs\1134123412.txt or non has been created.