I wrote the code below, at the moment I am testing, so there are no database queries in the code.
The code below, where he says if(filesize($filename) != 0), always goes to else, although the file is not 0 bytes and contains 16 bytes of data. I get nothing, it always seems that the file is 0 bytes.
It seems to me that it is easier for me to show my code (there may be other errors, but I check each error when I deal with them, one at a time). I am not getting any PHP errors or anything else.
$filename = 'memberlist.txt';
$file_directory = dirname($filename);
$fopen = fopen($filename, 'w+');
if(file_exists($filename) && is_writable($file_directory)){
clearstatcache();
echo "The file size is actually ".filesize($filename)." bytes.\n";
if(filesize($filename) != 0){
$fread = file($filename);
$current_time = time();
foreach($fread as $read){
$var = explode(';', $read);
$oldtime = $var[0];
$member_count = $var[1];
}
if($current_time - $oldtime >= 86400){
echo 'more than 24 hours has passed';
} else {
echo 'less than 24 hours has passed';
}
} else {
$current_time = time().' ; ';
$member_count = 582;
fwrite($fopen, $current_time.$member_count);
fclose($fopen);
}
} else {
echo 'file does not exist or is not writeable';
}
, , . script , 24 , member_count else, 24 , , - , .
1:
:
echo "The file size is actually ".filesize($filename)." bytes.\n";
, 0 .
0 .
var_dump (filesize($filename));
:
Int (0)