trailing zero bytes when using fwrite()
Posted: Wed May 14, 2008 10:16 am
Hi, I'm searching on the internet third day for solution and I cant find it. Im using logging to file in my php application. Everything works, but sometimes are after line of log several trailing zero bytes - \0 or 0x00. I have tried to trim written string, put there parameter lenght for fputs, or used other functions to write (fwrite, fprintf) but nothing helps.
$in_file is correct path to file
$in_description and $in_text are strings with no special chars but \t
Code:
Please help me.
$in_file is correct path to file
$in_description and $in_text are strings with no special chars but \t
Code:
Code: Select all
public static function write_to_file($in_file,$in_description,$in_text='')
{
if (!($f_handle = fopen ($in_file, "a")))
return $php_errormsg;
$data2save = "\n".format_date(time())." ".format_time(time())." $in_description\t$in_text";
fputs($f_handle,$data2save, strlen($data2save));
fclose($f_handle);
@chmod($in_file,0666);
return TRUE;
}