Php Show Error Reporting Level
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions php turn error reporting on you might have Meta Discuss the workings and policies of this php.ini error reporting site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers php error reporting disable or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a php error reporting not working community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How can I display (echo/print) the currently set error reporting level in PHP? up vote 17 down vote favorite 5 I am working on a rather large project (multiple teams) so I don't
Php Error Reporting Htaccess
have complete control over the code. Unfortunately, error_reporting is changed in many places throughout the code. When I get to a certain point in the code, I want to see what error reporting is currently set to. Is there anyway to accomplish this? php error-reporting share|improve this question asked Feb 6 '12 at 21:30 Trevor 8814 add a comment| 2 Answers 2 active oldest votes up vote 30 down vote accepted http://www.php.net/error_reporting int error_reporting ([ int $level ] ) Returns the old error_reporting level or the current level if no level parameter is given. You could also use examples provided by the link in order to cast the level (which is returned as integer) into the string. For example: function error_level_tostring($intval, $separator = ',') { $errorlevels = array( E_ALL => 'E_ALL', E_USER_DEPRECATED => 'E_USER_DEPRECATED', E_DEPRECATED => 'E_DEPRECATED', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', E_STRICT => 'E_STRICT', E_USER_NOTICE => 'E_USER_NOTICE', E_USER_WARNING => 'E_USER_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ER
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
Php Error Reporting Apache
Learn more about Stack Overflow the company Business Learn more about hiring developers php error reporting 22527 or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow error reporting php deprecated Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Showing all errors and warnings up vote 140 http://stackoverflow.com/questions/9167548/how-can-i-display-echo-print-the-currently-set-error-reporting-level-in-php down vote favorite 33 UPDATE 2: I have now removed the following from the .php file: I have set display_erros in php.ini as follows: display_errors = On error reporting is set to the following in php.ini error_reporting = E_ALL | E_STRICT After restarting apache, I still get no errors/warnings. UPDATE 1: I have changed error_reporting in php.ini from: error_reporting = E_ALL & http://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings ~E_DEPRECATED to error_reporting = E_ALL | E_STRICT After which I restarted apache, e.g. /etc/init.d/apache2 restart But the page will still not display errors/warnings of any kind. ORIGINAL QUESTION: The following script is generating an warning because the $err being inside the if statement. Why is this warning not being displayed on the php page in a web browser? I have to look at apache logs to see the warning. Also, if I delibarately change the "insert into" to "delete into", it does not display an error on the php page. Why are the errors not displaying on the actual php page?
changing the error reporting level programatically, but there may be times when it's needed. The nice thing is it's easily possible to get the http://www.electrictoolbox.com/php-get-modify-error-reporting-level/ current level, change it, and then set it back to what it was previously. Getting the current reporting level To get the curent reporting level simply call the error_reporting() function without passing any parameters, like so: $current_error_reporting = error_reporting(); This will return an integer value. You can see for example if E_NOTICE is set in the error reporting level like so: if($current_error_reporting & E_NOTICE) error reporting { // do something } Changing the error reporting level To change the error reporting level to something different, pass the new level as the parameter. The value return from the function call is the old error reporting level. The following example changes the error reporting level to everything but notices and stores the old level in a variable. $old_error_reporting = error_reporting(E_ALL ^ E_NOTICE); The php error reporting old error reporting level could then be restored at a later time: error_reporting($old_error_reporting); Removing notices from the current reporting level This final example removes E_NOTICE from the current reporting level, runs some other code, and then restores the old level back again. // remove E_NOTICE from error reporting and store previous value $old_error_reporting = error_reporting(error_reporting() ^ E_NOTICE); // run some other code // ... code ... // restore old error reporting level error_reporting($old_error_reporting); The above can be tested using the following code. It sets the error reporting level to E_ALL at the start so we can be sure when testing what the initial value is: error_reporting(E_ALL); echo error_reporting(), "\n"; $old_error_reporting = error_reporting(error_reporting() ^ E_NOTICE); echo error_reporting(), "\n"; error_reporting($old_error_reporting); echo error_reporting(), "\n"; This outputs 6143 6135 6143 which is to be expected: 6143 is E_ALL and 6135 is E_ALL without E_NOTICE. Related posts: Work out PHP's error reporting from an integer valueLog PHP errors with log_errors and error_logAutomatically append or prepend files in a PHP scriptPHP is not showing any error messagesTriggering errors with PHP Comments Categories ApacheApplicationsEmail ServersFCKEditorGlossaryHardware & GadgetsHTML and CSSInterspire Email MarketerJavascriptLaravel PHP FrameworkLemonStandLinux/Unix/BSDMicrosoft SQL ServerMiscellaneous PostingsMySqlNetworkingNginx Web ServerOffsite ArticlesOSXPHPQuick TipsRFCSendySilverS