Sandro Antonucci
Sandro Antonucci

Reputation: 1753

php parse errors won't show

I'm running ubuntu 10.04 + nginx + php-fpm 5.4

If I set display_errors = On in php.ini all errors are printed. If Instead I set that to off and then use ini_set('display_errors, '1'); directly in the script they will show as well but not the parse errors, just a blank page. I tried to play with error_reporting too and E_STRICT but I couldn't find a way!

Upvotes: 6

Views: 6532

Answers (5)

Tinsae
Tinsae

Reputation: 626

**You must enable error displaying in the php.ini file **

I have added ( un-commented ) the following lines, and the parse errors are being displayed now.

error_reporting 
Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED 
Development Value: E_ALL
Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

Upvotes: 0

Bob S
Bob S

Reputation: 131

here I am years after this was answered, but I found a way around this.

For the script I'm writing, I created a second script which includes the ini_set() directives, followed by an include for the script I really am working on.

To with, here is test_run.php

<?php

ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);

include('./my_script.php');

?>

Upvotes: 13

Chris Henry
Chris Henry

Reputation: 12010

Aside from turning on display_errors, you can also watch error logs. Typically, running Ubuntu + apache, your error log is going to be in /var/log/apache2/error_log. To watch in real time what's happening, you run something like tail -f /var/log/apache2/error_log.

This can sometimes be more straightforward than fussing with php settings.

Upvotes: 3

jadkik94
jadkik94

Reputation: 7068

Try error_reporting(E_ALL);. Or the docs

Upvotes: -1

Pascal MARTIN
Pascal MARTIN

Reputation: 401002

If you disable display_errors in php.ini, and later enable it in your PHP script using ini_set(), it will only be enabled after the line containing that ini_set() call has been executed.

Parse errors occur before the PHP script even starts -- when the PHP file is parsed (hence the "parse error" name).

Which means they occur before your ini_set() has even a chance of being executed -- which means that, in your case, display_errors is not enabled when the parse error occurs ; and, as a consequence, you don't get anything displayed.

Upvotes: 21

Related Questions