Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

file_exists with FILE_APPEND

$
0
0

I have this:

$txt = file_get_contents("http://example?a=".$text);
$file = "texts/".md5($text).".txt";
file_put_contents($file, $txt, FILE_APPEND);

and everything is okay. Except when I access the file again, $file values ​​are doubled. So I try to add if(!file_exists($file)):

$txt = file_get_contents("http://example?a=".$text);
$file = "texts/".md5($text).".txt";
if(!file_exists($file))
{
    file_put_contents($file, $txt, FILE_APPEND);
}

but that does not work, now FILE_APPEND containing only the first $txt values, not all. I hope you understand. Thanks.


Viewing all articles
Browse latest Browse all 13200

Trending Articles