PHP

I've dabbled with PHP in college, using template engines like smarty for college projects. Recently I've been heavily involved in setting up a Drupal based site, which has meant getting back into PHP to make various changes to the source to suit our needs.

Log to file

Had to log to file with PHP, used function below.

 1 <?php
 2 function logToFile($msg) { 
 3         // open file
 4         $filename = 'payments.log';
 5         $fd = fopen($filename, "a");
 6         // append date/time to message
 7         $str = "[" . date("Y/m/d h:i:s", mktime()) . "] " . $msg; 
 8         // write string
 9         fwrite($fd, $str . "\n");
10         // close file
11         fclose($fd);
12 }
13 ?>
blog comments powered by Disqus