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'm using XAMPP as my localhost server testing, and I'm using the CodeIgniter PHP framework for my web app.
When I want to test my web application, XAMPP doesn't load properly.
I've been waiting around a minute, and then what I get is just blank screen on the browser page.
I really need a local testing. But, oddly my CodeIgniter does work very well on my web hosting; no errors at all.
I'm using XAMPP v3.2.1, and my PHP version is 5.6.3.
Is there any custom configuration I should do?
And one more thing: this blank screen only appears when the model is trying to fetch data from database.
I have tested things like "Hello world" and it works fine. Any ideas?
Blank page is likely due to PHP errors with directives to display errors turned off. Check your php.ini for display_errors, html_errors and error_reporting directives. Should be:
display_errors = On
html_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
Because
* Your XAMPP works (because HelloWord program run correctly)
* Your web application on real server works. You check your routing configuration.
See more: https://ellislab.com/codeIgniter/user-guide/general/routing.html
(Try checking HTML source from blank page what you have seen, try enter url domain_at_localhost/[controler]/[action]/[param1]/[param2]... manually, and see result.)
I've looked around at a few different postings but haven't been able to find an answer to my problem. Recently I realized I wasn't using E_STRICT in my error_reporting, so I added error_reporting(E_ALL | E_STRICT) and have been going through debugging errors that I find.
The problem I am facing now is with error_reporting(E_ALL | E_STRICT) some of the pages won't load at all, I am given a white screen with no errors and no information as to what is wrong. If I use simply error_reporting(E_ALL) from the error_reporting everything loads fine..
I have the same error_reporting set up in my php.ini as well as my website.
I was also able to figure out exactly where the script was breaking (on an include_once for a file that does exist.)
I suppose I could survive with just using E_ALL as I have been up until now, but I am curious as to what the major problems are. Any help is much appreciated
As far as I'm concerned, the errors may be stored in the same directory in a file called error_log. My website host turned the reporting feature off, and all the errors are stored in the error_log file.
Completely based on experience.
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.
for my local machine i'm using the following setting in my php.ini
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
it allows omitting single quotes for fetching data from a recordset like $rs[url].
i've also used this setting on my webserver, but it simply ignores the syntax above and won't fetch any data. what could be wrong?
Are you sure you modified the right php.ini?
I ask that because sometimes, php.ini is located on various path, one for the php cli, the other for apache (and probably the case for other web server).
You should add more details about what server do you use (windows, linux), and which webserver are you using (apache, nginx, etc).
You should also be searching "php.ini" in your file system, maybe there is more than one file and you modified the wrong one, resulting in the problem you have.
Finally, and as mentionned in the comments, you shouldn't remove the deprecated errors and the notice in development environment, and have a "no error" code because an update is quite easy to make, and any deprecated function now, could result in a non working code after a quick apt-get update (for debian users).
Of course in production, you should hide all errors, but show a nice 404 or 500 page to your users and log the error for later investigation. :)
I am using Xdebug & Zend Framework 2
In my development environment I have mine set to:
error_reporting = E_ALL & ~E_USER_DEPRECATED & ~E_STRICT
I have found this to be my favoured setting when using ZF2.
If you're using PHP-FPM & NGINX The php.ini file is normally in found /etc/php5/fpm/.
Alternatively if you're using Apache with the PHP module, your php.ini file is normally in /etc/php5/
That error reporting level works for me as it I have found Zend Framework can throw some notices that are not relevant.