I'm trying to carry out a simple fwrite function which will write the contents of a particular array value to a txt file.
I know the code works fine because if I run the script via a web browser, my values are written as I want them to be.
However, as soon as I run the script via the command line (by running php.exe and passing it the location of the script), the files aren't written. I know the script is still running okay though as I get the output of the my array printed, but the files just don't get written to. I really can't understand this, it works fine when running through a browser.
I've come to the conclusion that it must be permissions related, but I've ensured that every user on the box (it's Windows) has full control over all files being used. I've tried running cmd.exe as administrator and then running the command, but that doesn't work either. Is it something to do php.exe not having the correct permissions? How can I ensure that it does?
Here is the code if you're interested, but like I said I know it works fine in the browser...
Code: Select all
$title2_txt = "2/title.txt";
$title2_handler = fopen($title2_txt, 'w');
fwrite($title2_handler, $arrFeeds['1']['title']);
fclose($title2_handler);