0

Is it possible to display PHP errors/warnings only if admin account has logged in. I want to make a content div for admin users where error are displayed and can be turned on/off.

Even with disabling error_report, I can still see errors.

How can I turn it off?

<?php 
error_reporting(0);
@ini_set('display_errors', 0);

echo "asf"2
?>

Page still shows the error

Parse error: syntax error, unexpected '2' (T_LNUMBER), expecting ',' or ';' in C:\xampp\htdocs\godhaze\index.php on line 5

By admin, I meant something like this

if(isset($_SESSION["usertype"])=="admin")
{
error_reporting(1);
@ini_set('display_errors', 1);
}
else
{
error_reporting(0);
@ini_set('display_errors', 0);
}

Also tried to read error_log.txt file, but getting error for file not found.

Somepub
  • 445
  • 2
  • 6
  • 22
  • You should report errors (log them) in any case, even if you don't display them – Qirel Jun 11 '17 at 14:07
  • The problem you have is a parse error which is very difficult to handle, have a look at https://stackoverflow.com/questions/1900208/php-custom-error-handler-handling-parse-fatal-errors for more info on error handling in certain circumstances. – Nigel Ren Jun 11 '17 at 14:07

0 Answers0