Created
September 19, 2021 10:48
-
-
Save fovelas/62ce980ea401d3a5e06c9a9c39c75a65 to your computer and use it in GitHub Desktop.
PHP Log Tutmak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('Europe/Istanbul'); | |
class Log | |
{ | |
public function add($text) | |
{ | |
$data = date("d.m.Y") . " " . date("H:i:s") . " " . $text . PHP_EOL; | |
$folder = "log/"; | |
$logFileName = $folder . date("d-m-Y") . ".log"; | |
if (!file_exists($folder)) { | |
mkdir($folder); | |
} | |
if (!file_exists($logFileName)) { | |
file_put_contents($logFileName, "\xEF\xBB\xBF"); | |
} | |
$ofile = fopen($logFileName, "a"); | |
fwrite($ofile, $data); | |
fclose($ofile); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "class.log.php"; | |
$log = new Log(); | |
$log->add("deneme log bu sekilde"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment