一个php日志类

<?php

//author:lixiuran

class Log {

    public static function writeLog($string) {

        $string = date('H:i:s') . ': ' . $string . "\r\n";
        $dir = dirname(__FILE__) . '/' . date('Y');
        if ( ! is_dir($dir)) {
            @mkdir($dir);
        }
        $filename = $dir . '/' . date('Y-m-d') . '.log';
        $handle = @fopen($filename, 'a');
        @fwrite($handle, $string);
        @fclose($handle);
    }
}

posted @ 2013-10-24 16:23  风与叶子  阅读(458)  评论(0编辑  收藏  举报