Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get PHP to report errors

I can't see any PHP errors. I have tried every trick I can find to turn error reporting on, but nothing works.

display_errors is on and error_logging is on, but when I view any page with an error, I get a blank page.

/var/log/php.log does not exist.

if I set a local logfile, Nothing gets created.

The file I have been testing with is

<?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
ini_set('error_log','script_errors.log');
ini_set('log_errors','On');


$a=

phpinfo();
?>

any other ideas?

like image 895
Nathan Avatar asked Aug 30 '10 23:08

Nathan


People also ask

Why is PHP not showing errors?

This is because, on many PHP based web server installations, PHP errors may be suppressed by default. This means that no one sees or is even aware of these errors. For this reason, it's a good idea to know where and how to enable them, especially for your local development environment.

How do I enable PHP error reporting?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

How do I show PHP errors in Chrome?

A: You can easily debug PHP in Chrome using a simple extension called PHP Console. Just install this PHP debugging tool from the Chrome web store and start logging errors, warnings, exceptions, and vars dump on your Chrome browser.


2 Answers

You probably need to set it in .htaccess, httpd.conf or php.ini (depending on your server or hosting company). You most likely have a parse error, which means your script never gets to the point where it can turn on the error reporting.

like image 147
Hans Avatar answered Sep 30 '22 05:09

Hans


Have you tried editing the actual ini file as opposed to trying to change it at runtime? You can also try using ini_get('display_errors'); to see if your change took effect. If neither of those work I would say your installation is either faulty or very restricted.

like image 35
leafo Avatar answered Sep 30 '22 06:09

leafo