Do I have to explicitly close this file?
<p>I found a <a href="http://www.redips.net/php/write-to-log-file/" rel="nofollow">logging script</a> like this:</p>

<pre><code>/** 
 * Logging class: 
 * - contains lopen and lwrite methods 
 * - lwrite will write message to the log file 
 * - first call of the lwrite will open log file implicitly 
 * - message is written with the following format: hh:mm:ss (script name) message 
 */  
class Logging{  
  // define log file  
  private $log_file = '/tmp/logfile.txt';  
  // define file pointer  
  private $fp = null;  
  // write message to the log file  
  public function lwrite($message){  
    // if file pointer doesn't exist, then open log file  
    if (!$this-&gt;fp) $this-&gt;lopen();  
    // define script name  
    $script_name = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);  
    // define current time  
    $time = date('H:i:s');  
    // write current time, script name and message to the log file  
    fwrite($this-&gt;fp, "$time ($script_name) $message\n");  
  }  
  // open log file  
  private function lopen(){  
    // define log file path and name  
    $lfile = $this-&gt;log_file;  
    // define the current date (it will be appended to the log file name)  
    $today = date('Y-m-d');  
    // open log file for writing only; place the file pointer at the end of the file  
    // if the file does not exist, attempt to create it  
    $this-&gt;fp = fopen($lfile . '_' . $today, 'a') or exit("Can't open $lfile!");  
  }  
} 
</code></pre>

<p>I can't see any file closing code here. Is that just fine? If not, at which point would that be appropriate? Or does PHP close the file anyways as soon as the script is completely executed (run through)?</p>
