I have php v5.3.2 on ubuntu 10.04. i changed the reporting options in /etc/php5/apache2/php.ini to these:
display_errors = 1
error_reporting = E_ALL
I also added these lines to the top of my php files and restarted apache but im still not able to see the errors/warnings,
ini_set('display_errors',1);
error_reporting(E_ALL);
Is there anything else in the way that prevents the errors from showing up?
Edit 1: According to phpinfo(), both display_errors and display_startup_errors are on.
The value of error_reporting is also 30719 which i'm not quite sure what it means.
Could you try error_reporting(-1); ?
Related
So what's going on is I tried
ini_set('display_errors', 'Off');
error_reporting(0);
Right below <?php, but this didn't seem to stop displaying them. So I went to the php.ini and went to display_errors and saw that it was set to Off. But it still showed.
So I went and did phpinfo() and display_errors along with display_startup_errors are both off. Also html_errors is off. I'm not sure if this will help, but it says error_reporting is set to -10241. Any ideas?
Do not change the value of error reporting to solve the issue. If display_errors is off, errors are not display independently of the error_reporting setting. This way you will not display errors but you can still log them.
The following should work:
ini_set('display_errors', 'Off');
If it doesn't work it could be that your server configuration does not allow you to change settings from PHP scripts. ini_set() returns FALSE on failure. So first of all you should check what value that call is returning. Make sure that ini_set is not listed among disabled PHP functions (disable_functions in php.ini).
If you are asking yourself why errors are still being displayed even if in php.ini the display_errors is Off, you can check the actual value of display_errors during the script execution:
ini_get('display_errors')
Pemember that PHP settings could be changed also in Apache host configuration and in .htaccess files. So check if you have an htacces that enables display_errors. Something like this:
php_flag display_errors on
Try to use:
ini_set('display_errors', 0);
ini_set('display_errors', false);
You don't describe what the errors are, so it's possible that your web server (Apache, nginx, etc) are what's throwing the error and not PHP.
If it is PHP, ensure that you're editing the correct php.ini as identified in your phpinfo.php. Remember that if you edit the php.ini, you will need to restart your PHP process (for example, on some *nix systems: service php-fpm restart. Your exact command may vary.)
If it's off in your php.ini, my guess is that it's being overridden somewhere else -- either later in the script ('grep "ini_set" /path/to/project/*.php' will find it). Also, the PHP Manual states that if the script has fatal errors, it doesn't apply if there are fatal errors:
Although display_errors may be set at runtime (with ini_set()), it
won't have any effect if the script has fatal errors. This is because
the desired runtime action does not get executed.
So really stuck at this point. My local environment which is using mamp will not display any errors at all.
I have established which php.ini it is loading so i am seeing the changes i am making changing in the phpinfo. But the log will no longer get generated and when i put dispaly_errors on as well nothing happens. Just blank screen.
settings below: (using mamp basic NOT pro)
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
error_log = "/Applications/MAMP/logs/php_error.log"
any help is appreciated. Driving me nuts :)
Thanks
/s
You can display errors by adding these lines directly in your PHP code:
ini_set('display_errors', 'On');
error_reporting(E_ALL);
For more details about errors handling you can read this post on my blog: Handle PHP errors and exceptions
I get a blank white page when running a script that I'm migrating from a Linux Apache server to IIS.
Following advice elsewhere on SO, I checked that the correct php.ini is being loaded. From phpinfo():
Loaded Configuration File C:\php\php.ini
In that php.ini file, I have the following:
error_reporting = E_ALL
display_errors = On
log_errors = On
error_log = "C:\Windows\Temp\php_errors.log"
For good measure, I have also added
ini_set( 'display_errors', 1 );
error_reporting(E_ALL);
in the script itself.
I'm getting no errors output to the screen, and the file C:\Windows\Temp\php_errors.log doesn't exist.
I'm obviously missing something; what is it? :)
I'm trying to get the warnings to show in my php error log.
My ISP has some warnings showing and I need to be able to see them on my test server.
error_reporting = E_ALL & ~E_NOTICE
display_errors = off
display_startup_errors = Off
log_errors = On
error_log = "C:\php-errors.txt"
I've upgraded my php version too 5.2.17
I also have
register_globals = Off
Like my ISP, but I can't get any warnings to show.
ini_set('display_errors', 'on'); is a great way to change php configurations settings specific for that page only. Include it in a global header/initialization file to make it application specific. Also, as mentioned before error_reporting(E_ALL); is good for this too.
Code at the top your scripts:
ini_set('display_errors', 'on');
error_reporting(E_ALL);
Be sure to use these only for development environments only.
Set display_errors to On to display the warnings in the page (instead of in the logfile) and set error_reporting to E_ALL | E_STRICT to display all warnings and errors in your php.ini.
If you want to show all possible warnings, try error_reporting(-1);, or you can put error_reporting = -1 into the php.ini file on your test server. It works, because the internal variable is used as a bit-field, and -1 sets all the bits on, hence, showing all possible errors.
To make sure that the error_reporting is still set to what you think, the variable returns the currently set level.
$prevErrLevel = error_reporting(-1);
echo "errlevel was: $prevErrLevel before setting to all.", __FILE__,':',__LINE__;
I am trying to setup PHP to log errors locally so that I can solve this problem.
However, I can't even get this to work. I have followed this tutorial, but nothing. Does it only log fatal errors or what?
Is there anything else I need to make sure of?
need these settings:
log_errors = on
error_reporting = E_ALL
if you want to set these in .htaccess, you can do somn like:
php_value log_errors 1
php_value error_reporting 6143