PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
the below code deletes the contents in the text file and then inserts the date into it.
==============================================
<?php
$first=open_file();
function open_file()
{
$for_date = date("H:i-j/m/y");
$fp = fopen ("c:\\sesha\\info.txt", "w");
//change the file to any text file you want.
//do use the escape character ''' in the windows.
if (!($fp))
{
exit;
}
while (!feof($fp))
{
$line = fread ( $fp, 1024 );
str_replace ('[a-zA-z0-9]+',"",$line);
}
fputs($fp," ");
fputs ($fp,"$for_date|$sh");
fclose ($fp);
}
?>
<body onLoad="<?php echo $first;?>">
===============================================
hope it helped
Note:
The mode may contain the letter 'b'. This is useful only on systems which differentiate between binary and text files (i.e. Windows. It's useless on Unix). If not needed, this will be ignored. You are encouraged to include the 'b' flag in order to make your scripts more portable.