Home  • Programming • PHP

Error reporting with PHP

Depending on whether you're programming/debbuging or installing a script on a production server, you may want error reporting more or less verbose. Here's how to change it:
<?
// Disable all error reporting
error_reporting(0);

// Default configuration
error_reporting(E_ALL ^ E_NOTICE);

// Display extra warnings about uninitialised variables, etc
error_reporting(E_ALL);
?> 

Comments 9


May be the alternative solution is error_reporting(E_ALL), parameter may be changed to E_NOTICE, NULL, you may also use carret Birthday cake , pipeline(|) etc depending on your purpose
and to change the reporting in our development environment we may also use ini_set() method.
Yes you can make lot of combination with using | or ^ as developer requirement
yes some configuration directive can be alter by php function ini_set() not all directive. you have to see the php manual if any particular directive is alter by php script or not
For example, the output_buffering setting is PHP_INI_PERDIR therefore it may not be set using ini_set(). However, the display_errors directive is PHP_INI_ALL therefore it may be set anywhere, including with ini_set(). 
http://php.net/manual/en/configuration.changes.modes.php
if there generates an error for the setting of PHP_INI_PERDIR or Output buffering, you will not get it , because it is the CORE_PHP_ERROR on your development environment, as example the max uploading file size is by default 4mb, but if you want to upload a file more than 4mb size , then the core error will occour, and it will not give you any msg.
if you want to change the setting to per directory level, than you have to mannually change it to php.ini file, May be there is alternative(like .htaccess file), but i prefer it, and to change the php.ini you must have to keep the right of an administrator
If you have VPS server then you will have that permission to customize your development environment as you want but not possible in the share hosting.
Yea, You are right!!!
Copyright © 2025. Powered by Intellect Software Ltd