sanjaypanditc
5/17/2017 - 11:50 AM

[PHP Codes] #php #php-log-file #errors #php-file-write

[PHP Codes] #php #php-log-file #errors #php-file-write

Generate PHP Error on a Specific IP Generate PHP Errors on a Specific IP

if($_SERVER["REMOTE_ADDR"] =='xxx.xxxx.xxx.xxx'){
  error_reporting(E_ALL);
    ini_set('display_errors','Off');
    ini_set("log_errors", 1);
    ini_set("error_log", "Your Error log path");
  # Your Error log path e.g "D:/xampp/htdocs/live/errors/lservererror.html"
}

Write a PHP File Write PHP Errors in a single file

##Generate file##
$arrayInfo =array();
$path = "/var/www/html/";
$fp = fopen($path."arrayDetails.txt", "a");
fwrite($fp, print_r($arrayInfo,true));
fclose($fp);