log Datei automatisch erzuegen

Kimble

Erfahrenes Mitglied
hi,
ich oeffne eine Datei so
PHP:
$tmp = fopen( $CFG['ERROR_LOG_DIR'] . "error.log", "a" );

aber wenn die Datei gar nicht existiert, wie kann ich sie dann automatisch erzeugen?
 
Zuletzt bearbeitet:
PHP:
if (file_exists($CFG['ERROR_LOG_DIR'] . "error.log"){
  $fp = fopen($CFG['ERROR_LOG_DIR'] . "error.log", "w+");
  fclose($fp);
}
$tmp = fopen( $CFG['ERROR_LOG_DIR'] . "error.log", "a" );


fertig! ;-)


Grüße, Ronin
 
oehm, muesst das nich:
PHP:
if(!file_exists($CFG['ERROR_LOG_DIR'] . "error.log" ) {
    ....
}
heissen, weil ich will ja eine neue erzeugen, wenn sie nich da ist.
 
Zurück