php parse errors won't show - php

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!

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.

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');
?>

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.

**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

Try error_reporting(E_ALL);. Or the docs

Related

PHP 7. I'm not able to display or log errors below. Is this possible? [duplicate]

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!
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.
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');
?>
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.
**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
Try error_reporting(E_ALL);. Or the docs

PHP cannot debug, errors only on server log [duplicate]

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!
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.
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');
?>
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.
**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
Try error_reporting(E_ALL);. Or the docs

Turn php error reporting off in xampp?

I just installed xampp, getting errors all over the place. Want to get rid of error handling. It's only annoying errors to do with my variables.
I'm not sure where to find php.ini, it doesn't exist in my C:\xampp\apache
Inside your php.ini make sure that you have display_errors to Off. From what I understand if you set display_errors to Off then the error_reporting directive doesn't need to change.
Example:
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
in php.ini, do the following change,
display_errors = Off
This is very old now, but in case someone comes across this there's a XAMMP issue with version 5.6.3. I had the same issue with error display set to 'off' and it was still showing up as on in phpinfo()
For some reason, they added the error reporting in php.ini twice. display_errors shows on line 99 of php.ini, and then again on line 552.
So if you scroll down and disable the first one, the second one is still set to 'on' and overrides the first one leaving error reporting active.
I'm sure this will be fixed with future versions of XAMMP, but wanted to add this here for anyone that comes here looking for an answer to this problem.
If you set display_errors=off then all types of error will of.
But if you only want to notice error off the you can set
error_reporting = E_ALL & ~E_NOTICE
Xampp and other web applications have an error interface to show programmers (and users) execution errors or warnings (notices).
In order to modify the way Xampp shows errors you have to go control panel and open php.ini.
Inside this file you can find two points to modify the way it shows errors:
“display_errors = On”. From my point of view it has to be On all the time. If you put Off you won’t have any info regarding bad sentences.
“error_reporting=E_ALL”. This is the key point. Changing the value of it you can change the way it shows errors.
Inside php.ini is documented all options. My favorites:
error_reporting=E_ALL  it shows everything. Good for debug.
error_reporting=E_ALL & ~E_STRICT & ~E_DEPRECATED  it shows errors & notice (very important for debugging) and not shows suggestions & deprecated functions in next php versions.
error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED  production environment not including Notices.
I hope this fit for you.
More details https://community.apachefriends.org/f/viewtopic.php?f=17&t=50989

PHP - Syntax errors no longer showing (blank white page)

Server got upgraded from PHP 5.2 to 5.3 and now I am no longer getting syntax errors, just a blank white page. I know this is a common question, and I normally know what needs to be done, I've just never had this situation before.
php.ini has display_errors on and error_reporting is set to E_ALL & E_NOTICE. Are there any other directives that could be affecting it? I used to get syntax error messages ("Unexpected ; in file on line...").
Am I being really stupid here?
I had the directive slightly wrong. The correct value in php.ini needs to be:
E_ALL & ~E_NOTICE
try in php.ini
error_reporting = E_ALL | E_STRICT
display_errors = On
save and restart apache
you didnt mention the OS but assuming you work on an Unix variant, you can see the errors by running this command :
tail -f /var/logs/apache2/error.log
or maybe
tail -f /var/log/httpd/error_log
And the web server configurations might have been changed too.

Do not receive certain PHP error messages

I am running Apache/PHP locally, and do receive errors in many cases, like uninitialized variables - but I have noticed a few cases where I do not receive error messages and am wondering if this is normal OR if I am missing out on anything,
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
$1a = "Hello world!";
echo $1a;
?>
Also producing no error:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
function a()
{
$b = 5;
echo $b;
}}
a();
?>
Does this script product PHP errors as it should for you? If so, I am wondering why I receive none. This is not an error I am likely to make, but there have been other times where I receive a blank page like above, where I would like some sort of feedback.
Your calls to ini_set never get executed, because the error happens in the parsing phase (i.e. before anything gets executed). You need to set those configuration values earlier in .htaccess, httpd.conf or php.ini.
Open up php.ini, and CTRL-F for display_errors - is it set to on? When I installed php I used ini_set(); to try and see errors and it didn't work, but editing the php.ini file worked.
Edit: I looked at your phpinfo() output on the page you posted, and it's set to off. Turn it on if you can. If I recall correctly, you have to restart apache after you edit it.
Edit2: In your php.ini file, error_reporting should be set to E_ALL & ~E_NOTICE (default), E_ALL | E_STRICT (development), or E_ALL & ~E_DEPRECATED (production). Honestly, that's all gibberish to me - but if it helps, mine is set to E_ALL & ~E_DEPRECATED, and I recieved errors from your code.

Categories