L
L
lol_vova2017-08-09 09:03:25
PHP
lol_vova, 2017-08-09 09:03:25

Why isn't a file being written when running PHP from the console?

There is a code:

$fp = fopen("1.txt", "a");
fwrite($fp, "example");
fclose($fp);

And when you run such code from the browser, everything works fine - such a file appears with such content. But if run through the console, the file is not created and, accordingly, nothing is written to it.
And the day before, everything worked from the console too. What could have happened or what is it connected with?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fortop, 2017-08-09
@lol_vova

Actually two options.
1. He writes, but not in the place you expect.
2. He does not write due to lack of rights.
For the first case, use
To know where the file is being written or is trying to write.
For the second case, check the results returned by fopen/fwrite.
And enable error display.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question