I am migrating from PHP4 to PHP5
I have this in my .htaccess:
php_flag display_errors on
php_value error_reporting 2039
Which used to show all errors.
I am still getting some errors but I used to get an error when I called a function that was not defined, but now it stops where it is at and send the client everything up to the error and nothing after. With no error message.
Here is what phpinfo is telling me:
Directive Local Value Master Value
display_errors On Off
error_reporting 2039 6143
I would like to be able to see my error messages for trouble shooting purposes.
Can someone tell me what I need to do? Thanks!!
If everything fails, just put this code at the beginning of your (/of each) script:
error_reporting(E_ALL);
ini_set('display_errors', 1);
This should show you all messages:
ini_set('display_errors', true);
error_reporting(E_ALL);
I'd guess that you PHP 5 version is >= PHP 5.2.0 and that the original error reporting level was E_ALL & ~E_NOTICE (or E_ALL ^ E_NOTICE, both have the same result).
Prior to PHP 5.2.0 E_ALL had a value of 2047, so your error level was 2039 due to not including the E_NOTICE level (of 8). As of PHP 5.2.0 E_ALL changed to 6143 (and as of PHP 5.3.0 to 30719) which means E_ALL & ~E_NOTICE is no longer 2039, but rather 6135 (or 30711 in PHP 5.3).
As for not displaying the errors (calling an undefined function should be a fatal error!), see the other answers.
Related
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
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
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
previously i had php5.1 installed and i recently upgraded to php5.3.
In previous versions all syntax errors and other errors were display in page whenever error occurs and it was easy for me to debug.
But now whenever there is error in page it just stops processing and shows blank.
i tried adding following too:
error_reporting(E_ALL & E_STRICT);
ini_set('display_errors', 1);
at top of page but didn't work. Any suggestions?
Edit more info:
when i do phpinfo(), it shows my configuration file: c:\php\php.ini.
Further on opening and editing php.ini file i found:
error_reporting = E_ALL
display_errors = On
Edit More Info:
Corrected error_reporting to E_ALL | E_STRICT.
Found it almost blanks out whenever the error is being generated from code inside function or class.
try this.
ini_set('display_errors','On');
whenever there is error in page
What level of error? Is it fatal or not?
If fatal - then your in-code settings (error_reporting() and ini_set) are not used at all: php.ini ones are used instead.
IMO, you've provided insufficient info: at least php.ini values you have for error_reporting and error_log directives needed.
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.