php log error code example
Example 1: how to create a logfile in php?
<?php
$log = "User: ".$_SERVER['REMOTE_ADDR'].' - '.date("F j, Y, g:i a").PHP_EOL.
"Attempt: ".($result[0]['success']=='1'?'Success':'Failed').PHP_EOL.
"User: ".$username.PHP_EOL.
"-------------------------".PHP_EOL;
file_put_contents('./log_'.date("j.n.Y").'.log', $log, FILE_APPEND);
Example 2: enable error logging php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
Example 3: php error log
/usr/local/apache/logs/error_log
Example 4: php error log
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);