Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting error_reporting in php.ini

Tags:

php

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?

like image 638
Fuxi Avatar asked Jun 06 '11 00:06

Fuxi


People also ask

How do I enable display errors in PHP?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); The ini_set function will try to override the configuration found in your php.

How do I turn off PHP error reporting?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>

How do I create a PHP error log?

The ini_set(“log_errors”, TRUE) command can be added to the php script to enable error logging in php. The ini_set('error_log', $log_file) command can be added to the php script to set the error logging file. Further error_log($error_message) function call can be used to log error message to the given file.


2 Answers

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. :)

like image 169
Cyril N. Avatar answered Oct 10 '22 08:10

Cyril N.


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.

like image 30
beingalex Avatar answered Oct 10 '22 08:10

beingalex