I'm using the basic MAMP on Mac, and PHP doesn't display errors, I already changed PHP and Apache configuration but still, can someone help me?
Not an answer, but I can't comment yet. Its obvious and a stupid thing to do, but if anyone else has this issue there are lots of comments in the php.ini, make sure you are changing the actual variable definition and not just a comment!
First of all make sure that you are editing the right file. MAMP usually creates several php.ini files. Call phpinfo() and check the path to the correct php.ini.
In your php.ini you need to set the following:
display_errors = on
error_reporting = E_ALL
Don't forget to restart Apache after the changes.
SOLUTION:
Bunyamin's comment was my solution.
display_errors for php5-fpm not working with nginx
The second answer of that question mentioned the /etc/php5/fpm/pool.d/*.conf files, in my case /etc/php5/fpm/pool.d/www.conf
There I added
php_flag[display_errors] = on
and now it works.
QUESTION:
I have already turned on error reporting in the /etc/php5/cgi/php.ini file and no errors are shown.
If I add
error_reporting(E_ALL);
ini_set('display_errors', 1);
to my PHP code, all the errors are shown.
Why doesn't it work if I turn on error reporting in the php.ini files and don't add that code snippet? Shouldn't the php.ini file do the same as the code?
Webserver: Lighttpd
OS: Raspbian Jessie
EDIT:
phpinfo() shows that display_errors is set to Off, but in the php.ini file its turned On.
My php.ini file: http://pastebin.com/1qeK310n
Output of phpinfo(): http://www.file-upload.net/download-11264468/phpinfo.htm.html
I have four suggestions.
First of all, make sure that you are editing the correct php.ini file. You can see which php.ini file is used with the function phpinfo().
Simply create a file, phpinfo.php, with the following content. When you load the page (http://yoursite.com/phpinfo.php), you can see the details about your PHP configuration.
<?php
echo phpinfo();
Secondly, make sure you set error_reporting to E_ALL to get full debug information (Suggested only in development).
Thirdly, is there anywhere in your application that you set display_errors to 0. Sometimes, especially in frameworks, this property is set to 0.
Lastly, sometimes Apache is configured in a way that a custom php.ini file located in the root directory of your webpage can override your global configuration. Then the change in global php.ini file would not affect your application.
You have to scroll down to where the display_errors is set to OFF an then turn it on (Don't uncomment and set to on, scroll down)
I just started to developp in a company. I'm totally unable to display PHP errors in my page so it is so annoying to make it work.
I have set :
display_errors = on
error_reporting = E_ALL
Do you have any idea about it ? Thanks!
If you made the changes in a php.ini, you should restart Apache.
If you made the changes in an Apache .conf file, you should reload Apache.
You may also add this code as the first line of the first file:
ini_set('display_errors',1);
Be sure to remove this setting from everywhere before using the code in a production environment.
I have a Ubuntu server running Apache2 with PHP 5. In the php.ini I set display_errors = On and error_reporting = E_ALL | E_STRICT, but PHP is still not displaying error messages. I'm also using Apache virtual hosts.
Also, what is the most strict error reporting PHP5.3 has to offer? I want my code to as up-to-date and future-proof as possible.
You also need to make sure you have your php.ini file include the following set or errors will go only to the log that is set by default or specified in the virtual host's configuration.
display_errors = On
The php.ini file is where base settings for all PHP on your server, however these can easily be overridden and altered any place in the PHP code and effect everything following that change. A good check is to add the display_errors directive to your php.ini file. If you don't see an error, but one is being logged, insert this at the top of the file causing the error:
ini_set('display_errors', 1);
error_reporting(E_ALL);
If this works then something earlier in your code is disabling error display.
I had the same issue and finally solved it. My mistake was that I tried to change /etc/php5/cli/php.ini, but then I found another php.ini here: /etc/php5/apache2/php.ini, changed display_errors = On, restarted the web-server and it worked! May be it would be helpful for someone absent-minded like me.
I had the same problem on my virtual server with Parallels Plesk Panel 10.4.4. The solution was (thanks to Zappa for the idea) setting error_reporting value to 32767 instead of E_ALL.
In Plesk:
Home > Subscriptions > (Select domain) > Customize > PHP Settings > error_reporting - Enter custom value - 32767
When you update the configuration in the php.ini file, you might have to restart apache. Try running apachectl restart or apache2ctl restart, or something like that.
Also, in you ini file, make sure you have display_errors = on, but only in a development environment, never in a production machine.
Also, the strictest error reporting is exactly what you have cited, E_ALL | E_STRICT. You can find more information on error levels at the php docs.
Check the error_reporting flag, must be E_ALL, but in some release of Plesk there are quotes ("E_ALL") instead of (E_ALL)
I solved this issue deleting the quotes (") in php.ini
from this:
error_reporting = "E_ALL"
to this:
error_reporting = E_ALL
Although this is old post...
i had similar situation that gave me headache.
Finally, i figured that i was including sub pages in index.php with "#include ..."
"#" hides all errors even if display_errors is ON
Make sure the php.ini that you're modifying is on the /etc/php5/apache2 folder, or else it won't have any efect...
Just want to add another pitfall here in case someone finds this question with a problem similar to mine.
When you are using Chrome (Or Chromium) and PHP triggers an error in PHP code which is located inside of a HTML attribute then Chrome removes the whole HTML element so you can't see the PHP error in your browser.
Here is an example:
<p>
test
</p>
When calling this code in Chrome you only get a HTML document with the starting <p> tag. The rest is missing. No error message and no other HTML code after this <p>. This is not a PHP issue. When you open this page in Firefox then you can see the error message (When viewing the HTML code). So this is a Chrome issue.
Don't know if there is a workaround somewhere. When this happens to you then you have to test the page in Firefox or check the Apache error log.
I had the same problem but I used ini_set('display_errors', '1'); inside the faulty script itself so it never fires on fatal / syntax errors. Finally I solved it by adding this to my .htaccess:
php_value auto_prepend_file /usr/www/{YOUR_PATH}/display_errors.php
display_errors.php:
<?php
ini_set('display_errors', 1);
error_reporting(-1);
?>
By that I was not forced to change the php.ini, use it for specific subfolders and could easily disable it again.
I have encountered also the problem. Finally I found the solution. I am using UBUNTU 16.04 LTS.
1) Open the /ect/php/7.0/apache2/php.ini file (under the /etc/php one might have different version of PHP but apache2/php.ini will be under the version file), find ERROR HANDLING AND LOGGING section and set the following value {display_error = On, error_reporting = E_ALL}.
NOTE - Under the QUICK REFERENCE section also one can find these values directives but don't change there just change in Section I told.
2) Restart Apache server sudo systemctl restart apache2
I know this thread is old but I just solved a similar problem with my Ubuntu server and thought I would add a note here to help others as this thread was first page in Google for the topic of PHP not displaying errors.
I tried several configuration settings for the error_reporting value in php.ini. From E_ALL | E_STRICT to E_ALL & E_NOTICE and none worked. I was not getting any syntax errors displayed in the browser (which is rather annoying on a development server). After changing the error_reporting setting to "E_ALL" it all started working. Not sure if it is an Ubuntu Oneric specific issue but after restarting Apache errors started showing in the HTML pages the server was serving. Seems the extra options confusing things and all error reporting stops. HTH somone else.
I just experienced this same problem and it turned out that my problem was not in the php.ini files, but simply, that I was starting the apache server as a regular user. As soon as i did a "sudo /etc/init.d/apache2 restart", my errors were shown.
I had the same problem with Apache and PHP 5.5.
In php.ini, I had the following lines:
error_reporting E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
display_errors Off
instead of the following:
error_reporting=E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
display_errors=Off
(the =sign was missing)
Though this thread is old but still, I feel I should post a good answer from this stackoverflow answer.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
This sure saved me after hours of trying to get things to work. I hope this helps someone.
When running PHP on windows with ISS there are some configuration settings in ISS that need to be set to prevent generic default pages from being shown.
1) Double click on FastCGISettings, click on PHP then Edit. Set StandardErrorMode to ReturnStdErrLn500.
StandardErrorMode
2) Go the the site, double click on the Error Pages, click on the 500 status, click Edit Feature Settings, Change Error Responses to Detailed Errors, click ok
Change Error Responses to Detailed Errors
For me I solved it by deleting the file of php_errors.txt in the relative folder. Then the file is created automatically again when the code runs next time, and with the errors printed this time.
I also face the same issue, I have the following settings in my php.inni file
display_errors = On
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
But still, PHP errors are not displaying on the webpage. I just restart my apache server and this problem was fixed.
I was a Windows user and used Wamp. Every time a PHP code failed, the browser would display something like this: error in line number xx.
I followed the installation of this tutorial and everything worked.
Now when code fail PHP just display a blank page.
Any sugestions?
(I'm using Ubuntu 10.04).
I know this is a old post, but I had the same problem and found out that after error_reporting, there is a option of display_errors, change it to On.
Old question, as Gurnarok noted, but still, here's the answer.
The standard LAMP server installation on Ubuntu does this. I simply call it "production" mode, i.e. your pages don't display errors (to your users) when your site goes live. I rather like that it does this, but I was confused at first, as well.
Instead of editing my php.ini file to go into "development" mode, I simply place this at the top of my PHP files (or, PHP file, in my case, since I usually pass everything through index.php):
ini_set('display_errors', true);
error_reporting(E_ALL ^ E_NOTICE);
So, the reason why error_reporting by itself isn't doing the trick, is most likely because display_errors isn't set to true in your php.ini file. The code above should take care of that.
I prefer to exclude the PHP "Notice" notification, such as notifications about non-existent array keys (the most common Notice, in my case), but you're perfectly welcome to simply change this to error_reporting(E_ALL);
Of course, you can set these variables in the php.ini file, I simply prefer it this way, so that when the site goes live, I simply remove those two lines from index.php and I'm in no danger of errors showing up to my users.
Find php.ini under /etc/php5/apache2/ and set the value of error_reporting to E_ALL. Like:
error_reporting = E_ALL
Or alternatively check error.log if your virtual host is providing one.
Thanks Phil your answer got me thinking and I finally managed to fix an issue thats been bugging me for weeks where my PHP install wasn't displaying errors in the HTML page at all (except sometimes a notice message but never any syntax errors etc). Even though I had all other error settings set to "on" and log_errors set to on and a filename for the log only notices were getting logged to the log file but never any syntax errors. Not very useful on a development server :)
Thought I would post my findings here in the hope that this info can help someone else with the same issue as Google wasn't very helpful with fixing the issue.
In older versions of PHP before PHP 5 I used to always have my error reporting setting in PHP ini set to "E_ALL & E_NOTICE" on my development servers. In later versions of PHP (well with my Ubuntu Oneric install anyways) using this setting seems to cause no output to be displayed at all in the HTML page regardless of the other php.ini settings (like display_errors = on, etc). Setting the values on the fly in a PHP page didnt help either as it seems the php.ini value overrides the per file setting.
I changed the error_reporting value to "E_ALL" only and now it displays syntax errors. The setting recommended in php.ini for a development server (E_ALL | E_STRICT) doesnt work for me either so thanks a lot. +1 to you :)