$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$randstring = '';
for ($i = 0; $i < 10; $i++) {
$randstring .= $characters[rand(0, strlen($characters))];
}
echo $randstring;
Chinnayya.Blogspot is a Software Development tutorial site passionately maintained by Chinnayya Naidu Nalla. Tutorials written are of Java, Servlets, Jsp, Spring framework, JavaScript and design patterns. Chinnayya.Blogspot stands out from the crowd by providing in-depth tutorial on each topic at the same time keeping it simple. This helps to refresh your knowledge, keep updated and Happy Learning. Welcome!
Tuesday, 31 March 2015
Generating a Log File In PHP
$log = "-----------Chinnayya Naidu Nalla's Application Accesed on".date("Y-m-d H:i:s"). "--------------".PHP_EOL.
"User: ".$_SERVER['REMOTE_ADDR'].' - '.date("F j, Y, g:i a").PHP_EOL.
"-------------------------".PHP_EOL;
file_put_contents('./log_'.date("j.n.Y").'.txt', $log, FILE_APPEND);
Place this code in your Php code it will generate a log file in your application. to achieve polymorphic nature place this in a function in a separate php file and include it. remember to create a function with a parameter to pass the log message to it Logging Code in a function with a parameter
function WriteLog($logmessage){
file_put_contents('./log_'.date("j.n.Y").'.txt', $logmessage, FILE_APPEND); }
"User: ".$_SERVER['REMOTE_ADDR'].' - '.date("F j, Y, g:i a").PHP_EOL.
"-------------------------".PHP_EOL;
file_put_contents('./log_'.date("j.n.Y").'.txt', $log, FILE_APPEND);
Place this code in your Php code it will generate a log file in your application. to achieve polymorphic nature place this in a function in a separate php file and include it. remember to create a function with a parameter to pass the log message to it Logging Code in a function with a parameter
function WriteLog($logmessage){
file_put_contents('./log_'.date("j.n.Y").'.txt', $logmessage, FILE_APPEND); }
Saturday, 14 March 2015
Subscribe to:
Posts (Atom)