F
F
fremsisRus2018-01-01 19:25:00
linux
fremsisRus, 2018-01-01 19:25:00

Why can't I clean up a file with php?

There is this code:

<?php
$fo = fopen("cookie.txt", "w");
fclose($fo);
?>

stuck in cron
*/1 * * * * /usr/bin/php /home/polzak/ful/index.php

rights set the rights to the file like this:
suod chmod 777 ~/ful/cookie.txt
but the file is not cleaned, why?
PS
Linux server-home 4.9.0-4-686-pae #1 SMP Debian 4.9.51-1 (2017-09-28) i686 GNU/Linux

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Toropov, 2018-01-01
@nefone

And why should it be cleared, you just tear it off for writing, having received the descriptor and immediately close it.
You can write an empty string to it using the fwrite() function.

<?php
$fo = fopen("cookie.txt", "w");
fwrite($fo, "");
fclose($fo);
?>

T
Troodi Larson, 2018-01-01
@troodi

Or easierfile_put_contents('cookie.txt', '');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question