Forum Moderators: coopster

Message Too Old, No Replies

PHP file write

         

andrewsmd

5:24 pm on Jul 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have php code that searches through a log file for the text log notes for mmddyyy (being the current date). If it is not there the script writes that, otherwise it just writes a message that is passed into it. However I would like to write that text to a file and make it stand out in some way (i.e. a bigger font or bold or something). Does anyone know how to do this. Here is the code that writes the message to the text file.

function writeFile($data){

//get the date
$date = date("Y-m");
$date2 = date("Y-m-d");
$name = "\\\\machineName\\folder\\Send Log\\{$date}-log.txt";
$contents = file_get_contents($name);

//check to see if we have written the date to the log file yet.
if((strpos($contents, "Log notes for {$date2}") === FALSE)){

$fo = fopen($name, 'a');
fwrite($fo, "\nLog notes for {$date2}\n");
fclose($fo);

}//if strpos

$file = fopen($name, 'a');
if(fwrite($file, "{$data}\n"));

else{
echo("There was an error writing to the log file");
die();
}
fclose($file);

}//function writeFile

eelixduppy

8:02 pm on Jul 30, 2008 (gmt 0)



You are writing to a simple text file, which has no formatting. To make it "stick out" more you can do things like add astericks around it, such as "***text***" although formatting like font size and weight are something you'd have to use another file type for. There are MS Word classes that will enable you to write to Word document in PHP. There are other file types you can mess around with, too.

andrewsmd

8:54 pm on Jul 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What would those other file types be and are any of them simple enough because we go all the way from windows 2000 to vista and everything in between. But, thanks for the idea I will probably do that.