Page 1 of 1

Rand and file_put_contents

Posted: Fri Dec 30, 2011 5:36 pm
by smadonnatore
I'm going mad.
Here it is a single line code snippet

Code: Select all

<?php
file_put_contents("/var/www/test/" . rand() . ".html", "test");
?>
It should create 1 file with content "test", but every times it's executed it creates 2 files with the same content.
How is it possible?

Thanks.

Re: Rand and file_put_contents

Posted: Sat Dec 31, 2011 12:50 am
by twinedev
As is, the code above would not do that. How is that line of code (and/or the file it is in) called?

-Greg

Re: Rand and file_put_contents

Posted: Sat Dec 31, 2011 4:29 am
by gameraider
smadonnatore wrote:I'm going mad.
Here it is a single line code snippet

Code: Select all

<?php
file_put_contents("/var/www/test/" . rand() . ".html", "test");
?>
It should create 1 file with content "test", but every times it's executed it creates 2 files with the same content.
How is it possible?

Thanks.
Did you set the FILE_APPEND flag ??