Kimble Erfahrenes Mitglied 5. Februar 2003 #1 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: 5. Februar 2003
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?
R ronin Erfahrenes Mitglied 5. Februar 2003 #2 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
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
Kimble Erfahrenes Mitglied 5. Februar 2003 #3 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.
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.