PHP error reports by localhost - How?
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
PHP error reports by localhost - How?
My server give the errors in a php file when it is run, and the line, and the file location, etc. But, my localhost I have setup on my computer does not. Is this an add on that one must download from php.net? Any advice much appreciated. 
Have a look in your php.ini
You can configure how error reports will be handled.
If you want to know where this file is, run phpinfo(), for example:
Loaded Configuration File C:\php\php.ini
There are 2 settings that effect error reports.
Both of them can can be changed in your scripts, as well in php.ini.
- display_errors = On/Off
- error_reporting = E_ALL (shows everything, including E_NOTICES)
- error_reporting = E_ALL &~ E_NOTICES (shows Errors and Warnings, but not notices.)
Read more in your php.ini file and here:
http://php.net/error_reporting
You can configure how error reports will be handled.
If you want to know where this file is, run phpinfo(), for example:
Loaded Configuration File C:\php\php.ini
There are 2 settings that effect error reports.
Both of them can can be changed in your scripts, as well in php.ini.
- display_errors = On/Off
- error_reporting = E_ALL (shows everything, including E_NOTICES)
- error_reporting = E_ALL &~ E_NOTICES (shows Errors and Warnings, but not notices.)
Read more in your php.ini file and here:
http://php.net/error_reporting
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Thanks for the reply. I did as you said, and un-commented display_errors, and set it to On, and un-commented error_reporting, and set it to E_ALL. It still doesn't work. Do you have to restart you computer to make it work? I did try restarting the Apache service, but that didn't work either. Thanks for your help so far 
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Thanks, everyone. It works now. I was setting the display_errors and error_reporting on lines 74 and 102. I scrolled down, and found the same settings, (set to Off, of course) on lines 349 and 356. I wonder why
P.S. sorry for the repeated post. I'm on dialup, and is really slow right now, and posting.php didn't open, so didn't know it was posted anyway.
P.S. sorry for the repeated post. I'm on dialup, and is really slow right now, and posting.php didn't open, so didn't know it was posted anyway.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Yes.
After each change in php.ini you would have to restart server.
This is true for Apache and most servers. (There are other servers that work differently, though)
Because Apache loads the php.ini settings once.
At server program start.
After each change in php.ini you would have to restart server.
This is true for Apache and most servers. (There are other servers that work differently, though)
Because Apache loads the php.ini settings once.
At server program start.
Last edited by phpBuddy on Mon Nov 12, 2007 3:16 am, edited 1 time in total.
Yes.feyd wrote:That would depend on what your error_log setting is.
And it can be the path to any file you want.
For example: error_log = 'c:/php/mylogs/errors.log'
You have to create the directory /mylogs/, but the file is created automatically.
Just as the other log settings, error_log can be set in your script
which will temporarily override you php.ini setttings.
The settings in beginning of this script will turn Off display errrors
and log all errors happening in this script to a file in same directory instead.
Code: Select all
<?php
error_reporting( E_ALL );
ini_set('display_errors', '0');// ini_set() can change php.ini settings
ini_set('log_errors', '1'); // but will only effect current script
ini_set('error_log', dirname(__FILE__).'/_phperror.log');//directory of this file
// test some errors
include( 'missing.file' );
$hello = 'hello';
echo $helo;
?>- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California