I've looked for solutions to show error on my local php website, but beside setting display_errors through
ini_set('display_errors','1');
error_reporting(E_ALL);
or through .htaccess file, I can't make my website to show error. Although it seems that my default setting of display_errors has no problem at all.
Is there anyone could help me with this? Or I just have to save a .htaccess file every time I try to run something.
Apparently I'm still pretty new to PHP, and that's part of the reason I really try to know what's going on here and save myself some time while I'm learning many ideas and function of PHP.
many thanks!
part of my php.ini and this is the right version php.ini file that my server loads.
I think this is the part of php.ini file I should edit.
Working on to test the result!
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On
Problem solved!
I didn't get edit the right part of the code in the first hand.
Related
So, I have 500 error on a page and I want more information why I do have error (because the page works fine in local but not on my server)
I try the following solution preconised in This topic but it doesn't help. I restarted nginx everytime and no changes.
Here is the folder on my server (VPS, no cPanel) :
here is my actual state of php.ini :
http://pastebin.fr/75379
Any clue ?
What you placed at the top of your PHP.INI file is what you would use in an actual .php file to turn on error reporting / show errors on a per file bases. You do not add that to your PHP.INI file.
Example of use in a .php file:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
If you search your PHP.INI file you will find error_reporting = E_ALL, and display_errors = On are set.
Notice the definitions in the PHP.INI file:
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On
You should not display errors in a production environment. You don't want to reveal any extra information to any potential hackers. Also these errors will mean nothing to your users. You should just show a generic error page and log all your errors for your review.
In a development environment I would have them all on and display_startup_errors = On.
I see log_errors = On so you should be getting your error messages logged to:
/var/log/nginx/default-error.log. I suggest looking there to find your issue after you fix your PHP.INI file.
What is the most convenient way of error reporting in finished website? I would like to still log exceptions and errors to external file. I definitely don't want the user to see anything more than "Error: something went wrong, we are lookin into it".
Does my try - catch work and can I log my Exceptions if I set:
error_reporting(0);
In your php.ini file you should hide errors:
display_errors = Off
If you want to know about any errors that occur (you should care) you should turn on error logging:
log_errors = On
How to set error reporting depends on what errors you want to know about. Ideally you should want to know about everything (maybe except errors about deprecated stuff; if the website is already done then you should have fixed any such errors). See this page for more information.
; Show everything except deprecated errors
error_reporting = E_ALL & ~E_DEPRECATED
And then there are a few more things you can set:
; It makes little sense to have this on
html_errors = Off
; Set this to where your log file should be stored
error_log = /path/to/log/file.log
; Maybe more, see link below...
You can see some more options here.
Restart your server after making changes to php.ini.
For some reason on this particular script, which is a copy of a script I use in a lot of other places, I am not getting any PHP errors. It simply shows a blank page, and It took me a long long time to hunt down a missing semi-colon this morning. Why arn't errors showing up?
my PHP.INI for this sub-domain:
display_errors = On
short_open_tag = On
memory_limit = 32M
date.timezone = Europe/Paris
The code at the top of the page:
session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
The Sub Domain is set to run PHP as an Apache Module Which is the same as every other domain I use.
So I am not sure why I am not getting errors displayed. Can anyone tell me?
EDIT:
This is solved, because the errors I was producing were on the page where I had got the lines:
error_reporting(E_ALL);
ini_set('display_errors', '1');
written. When I put the error on to a seperate page and included it, I could see the error fine.
I guess that's why they use bootstrapping!
You should set error_reporting to E_ALL in the php.ini as well: when a parse error occurs (such as a missing semicolon), your error_reporting(E_ALL) won't be used.
You could try to change this lines to get more information from php:
; The display of errors which occur during PHP's startup sequence are handled
; separately from display_errors. PHP's default behavior is to suppress those
; errors from clients. Turning the display of startup errors on can be useful in
; debugging configuration problems. But, it's strongly recommended that you
; leave this setting off on production servers.
display_startup_errors = On
; When PHP displays or logs an error, it has the capability of formatting the
; error message as HTML for easier reading. This directive controls whether
; the error message is formatted as HTML or not.
; Note: This directive is hardcoded to Off for the CLI SAPI
html_errors = On
error_reporting(E_ALL);
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
I have a WAMP 2.2 server running on a Windows 7 box and cannot get PHP error logging working at all.
The file is always blank even after I explicitly trigger USER_ERROR errors, or cause normal ERROR errors.
I'm including the error relevant sections of the php.ini file - hopefully you can find something:
error_reporting = E_ALL
error_log = "c:/wamp32/logs/php_error.log" ;(UNCOMMENTED BY ME)
log_errors = On
display_errors = On
The line ; log_errors is just a comment for the following block, for the purpose of showing you what the settings are in dev vs production. You uncommented four lines which aren't meant to control anything, and I'm surprised your Apache service doesn't have problems starting up because of it.
What you need to do is look for the line:
log_errors = Off
And change the value to On
That said, once you restart the Apache service, the settings should take effect. However, I was unable to get WampServer to properly log php errors despite these settings. Apache will not start up when I specify the error_log parameter.
For me it turned out to be a permissions error. I ended up giving EVERYONE full control of the error log file and it seemed to fix my issue. Best of luck.
Did you try adding these lines to your php file?
ini_set("display_errors", "1");
ini_set("log_errors", "1");
ini_set("error_log", "/wamp64/logs/php_error.log");
i have done onw project in php. It works on my windows pc. I use xampp on my windows machine.But when i devlopy same on my linux machine it shows me some blank pages.
Some pages are completely blank.some are half blank.
whats the problem?
Those blank pages could be because there is an error that is not displayed -- will be hard to guess what, though, so here are a couple of pointers :
Did you check if there is anything useful in your Apache's log files (something like /var/log/apache/error.log, or close to that, generally).
You can also enable display_errors and/or configure error_reporting, to get more informations -- or have them displayed on screen, which might be a bit easier, as long as you are developping and your application is not deployed to the production server.
This can be done in the php.ini file, if you can modify it, with something like this :
error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On
Or it can also be done directly in your code, at the beginning of it, with something like this :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
To enable error_reporting for all kinf of errors, and display those errors.
You might also want to install Xdebug on your development box, to get nice stacktraces when an error / exception occurs -- just don't install it on a production server !
Of course, on your production machine, you probably don't want to display errors ; so that will have to be configured depending on your environment ;-)