search
Homephp教程PHP源码一个安全的快速写日志的函数

php代码

<?php

/**
 * 直接记录日志
 * @param$lvevel
 * @param string $level
 *  http://www.phpqee.com
 */
function Write($msg, $level) {
    $arr_level = explode(&#39;,&#39;, YUC_LOG_TYPE);
    if (in_array($level, $arr_level)) {
        $record = date(&#39;Y-m-d H:m:s&#39;) . " >>> " . number_format(microtime(TRUE), 5, ".", "") . &#39; &#39; . " : " . $level . "\t" . $msg;
        $base = M_PRO_DIR . "/Log";
        $dest = $base . "/" . date("YmdH", time()) . &#39;log.php&#39;;
        if (!file_exists($dest)) {
            @mkdir($base, 0777, TRUE);
            @file_put_contents($dest, "\r\n", FILE_APPEND);
        }
        if (file_exists($dest)) {
            @file_put_contents($dest, $record . "\r\n", FILE_APPEND);
        }
    }
}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!