Skip to content

Instantly share code, notes, and snippets.

@fovelas
Created September 19, 2021 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fovelas/62ce980ea401d3a5e06c9a9c39c75a65 to your computer and use it in GitHub Desktop.
Save fovelas/62ce980ea401d3a5e06c9a9c39c75a65 to your computer and use it in GitHub Desktop.
PHP Log Tutmak
<?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);
}
}
<?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