[Php-it] "logs/log." . date('d-m-Y H:i:s') . ".txt"

Alessandro Marinuzzi alecosnet at inwind.it
Wed Dec 20 15:59:23 CET 2006


Cristiano Verondini ha scritto:
>
>     @mkdir("logs/");
>     $text = @fopen("logs/log." . date('d-m-Y H:i:s') . ".txt", "w+");
>     $logs .= "Date: " . date('d-m-Y H:i:s') . $eol;
>     $logs .= "To: $mail" . $eol;
>     $logs .= $headers . $eol;
>     $logs .= "Subject: $subject" . $eol;
>     $logs .= "Message: $message" . $eol;
>     fwrite($text, $logs);
>     fclose($text);
>
>     Al di la del problema specifico (direi i ':' nel nome del file),
> l'uso del '@' <mailto:%27@%27> ha ovviamente causato dei problemi.
> Inoltre devi prevedere che la fopen() fallisca, quindi:
>  
>         $text = fopen(...);
>         if ($text !== FALSE) {
>  
>             fwrite(...);
>             fclose(...);
>         }
>  
> -- 
> Cristiano Verondini
> http://www.verondini.it  ---   [ICQ: 114 190]
>  
Lasciamo stare per un attimo l'if e vediamo come si può formattare
meglio il log per una lettura più confortevole...
Ho pensato di mandare a capo oltre i 58 caratteri usando wordwarp... che
ne pensate? lascio il log com'è o lo formatto?

       @mkdir("logs/");
        $text = @fopen("logs/log-" . date('d-m-Y_H.i.s') . ".txt", "w+");
        $logs .= "Date: " . date('d-m-Y H:i:s') . $eol;
        $logs .= "To: $mail" . $eol;
        $logs .= $headers . $eol;
        $logs .= "Subject: $subject" . $eol;
        $logs .= "Message:" . $eol . wordwrap($message, 58, $eol) . $eol;
        fwrite($text, $logs);
        fclose($text);

Ciao e grazie :-)

-- 
Alessandro Marinuzzi
---------------------
http://www.alecos.it/
---------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ziobudda.net/pipermail/php-it/attachments/20061220/f8e683f7/attachment.htm


More information about the Php-it mailing list