Answers for "error_log php"

PHP
8

how to create a logfile in php?

<?php
//Something to write to txt log
$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;

//Save string to log, use FILE_APPEND to append.
file_put_contents('./log_'.date("j.n.Y").'.log', $log, FILE_APPEND);
Posted by: Guest on August-28-2020
1

how to see php error log

/usr/local/apache/logs/error_log
Posted by: Guest on April-21-2020
0

php error log

// Php Error Log
error_log("Error message");

// Log and Array
error_log( print_r( [
  __METHOD__,
  'error_key_1' => 'error_value'
] ) );
Posted by: Guest on August-10-2021
0

log php

For those interested. Works with older than 4.3 versions.

<?php
    function byteConvert($bytes)
    {
        $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB');
        $e = floor(log($bytes)/log(1024));
      
        return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
    }
?>
Posted by: Guest on September-23-2021

Browse Popular Code Answers by Language